Skip to content

Commit

Permalink
Fix Error when creating empty RSS feed on PHP 8
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dregad committed Feb 13, 2024
1 parent 7dcb81c commit 9a8f127
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions library/README.md
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions library/rssbuilder/class.ObjectList.inc.php
Expand Up @@ -4,7 +4,7 @@
* Class for creating an RSS-feed
* @author Michael Wimmer <flaimo@gmail.com>
* @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
Expand All @@ -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) {
Expand Down Expand Up @@ -68,4 +68,3 @@ public function getIterator() {
return new ObjectIterator($this);
} // end function
} // end class
?>

0 comments on commit 9a8f127

Please sign in to comment.