From 9a8f1277c1b0a2577ffee9c110e56d73a2ae7f10 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Tue, 13 Feb 2024 16:39:01 +0100 Subject: [PATCH] Fix Error when creating empty RSS feed on PHP 8 When the feed is empty, ObjectIterator::size() throws a TypeError exception on PHP 8.0+ (and a Warning on PHP 7.2+) due to calling count() on $this->objectlist->objects, which is null in this case. Initializing the ObjectList::$objects property to an empty array ensures this never happens. File was converted to UTF-8 and trailing ?> removed. Fixes #33634 --- library/README.md | 10 +++++----- library/rssbuilder/class.ObjectList.inc.php | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/library/README.md b/library/README.md index 22d55515a1..74265d41fd 100644 --- a/library/README.md +++ b/library/README.md @@ -6,9 +6,9 @@ The version and status of each is summarized below: ## PHP libraries -| directory | project | version | status | -|------------|------------|---------|----------------| -| rssbuilder | RSSBuilder | 2.2.1 | patched [1][2] | +| directory | project | version | status | +|------------|------------|---------|---------------------| +| rssbuilder | RSSBuilder | 2.2.1 | patched [1],[2],[4] | ## Javascript/CSS libraries @@ -30,10 +30,10 @@ The version and status of each is summarized below: **Notes** 1. removed `__autoload` function -2. fixed SYSTEM NOTICE 'Only variables should be passed by reference' +2. fixed SYSTEM NOTICE 'Only variables should be passed by reference' (#25213) 3. fixed scrolling regression in navigation buttons, patch submitted upstream https://github.com/javve/list.js/pull/750 - +4. fixed TypeError when creating empty feed on PHP 8 (#33634) ## Upstream projects diff --git a/library/rssbuilder/class.ObjectList.inc.php b/library/rssbuilder/class.ObjectList.inc.php index 9740bd7f67..038399b61b 100644 --- a/library/rssbuilder/class.ObjectList.inc.php +++ b/library/rssbuilder/class.ObjectList.inc.php @@ -4,7 +4,7 @@ * Class for creating an RSS-feed * @author Michael Wimmer * @category flaimo-php -* @copyright Copyright © 2002-2008, Michael Wimmer +* @copyright Copyright © 2002-2008, Michael Wimmer * @license GNU General Public License v3 * @link http://code.google.com/p/flaimo-php/ * @package RSS @@ -14,7 +14,7 @@ abstract class ObjectList extends RSSBase implements IteratorAggregate { protected $size = 20; protected $offset = 0; - public $objects; + public $objects = []; protected $factory; function __construct($offset = 0, $size = 20) { @@ -68,4 +68,3 @@ public function getIterator() { return new ObjectIterator($this); } // end function } // end class -?>