View Issue Details

IDProjectCategoryView StatusLast Update
0033634mantisbtrsspublic2024-02-20 16:58
Reportertm8544 Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformPHP 8.3.2OSWindowsOS Version11
Target Version2.26.1Fixed in Version2.26.1 
Summary0033634: Error in creating RSS when there are no issues to publish
Description

count(): Argument 0000001 ($value) must be of type Countable|array, null given
..\bugtracker\library\rssbuilder\class.ObjectIterator.inc.php: 23: ObjectIterator - -> - size()
..\bugtracker\library\rssbuilder\class.RSS_V_200.inc.php: 168: ObjectIterator - -> - valid()
..\bugtracker\library\rssbuilder\class.RSS_V_abstract.inc.php: 36: RSS_V_200 - -> - generateXML()
..\bugtracker\library\rssbuilder\class.RSSBuilder.inc.php: 195: RSS_V_abstract - -> - outputRSS()
..\bugtracker\issues_rss.php: 240: RSSBuilder - -> - outputRSS()

Steps To Reproduce

Install bugtracker, create some projects but do not create issues. Try to create rss.

Additional Information

Changelog for count()
8.0.0 count() will now throw TypeError on invalid countable types passed to the value parameter.
7.2.0 count() will now yield a warning on invalid countable typespassed to the value parameter.

On bugtracker\library\rssbuilder\class.ObjectIterator.inc.php, modify function size() as follows

public function size() {
if ($this->objectlist->objects === null) return 0;
return count($this->objectlist->objects);
} // end function

Tagspatch, PHP 8

Relationships

related to 0024145 new Replace rssbuilder with a well maintained library via composer 

Activities

dregad

dregad

2024-02-13 03:01

developer   ~0068530

The RSS library we use is very outdated and unmaintained. Replacing it is tracked here 0024145. I actually started working on that several years ago, but it's not a priority for me and I never finished the work (see https://github.com/dregad/mantisbt/tree/rssbuilder-replace). If you or anyone else wishes to pick up on that feature branch, be my guest.

Until then, we have already patched it in the past so it should be no issue to fix this PHP-compatibility issue too, I'll have a closer look as time allows.

Would you mind submitting your proposed fix as a Pull request ?

dregad

dregad

2024-02-13 08:30

developer   ~0068531

Last edited: 2024-02-13 10:37

PR https://github.com/mantisbt/mantisbt/pull/1965

Related Changesets

MantisBT: master-2.26 0e241f33

2024-02-13 03:44

tm8544

Committer: dregad


Details Diff
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.

Fixes 0033634

Signed-off-by: Damien Regad <dregad@mantisbt.org>

- Rewrote original commit message
- Fixed whitespace
- Updated library\README.md
- Removed closing `?>` tag
Affected Issues
0033634
mod - library/README.md Diff File
mod - library/rssbuilder/class.ObjectIterator.inc.php Diff File

MantisBT: master-2.26 9a8f1277

2024-02-13 10:39

dregad


Details Diff
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 0033634
Affected Issues
0033634
mod - library/README.md Diff File
mod - library/rssbuilder/class.ObjectList.inc.php Diff File

MantisBT: master-2.26 7dcb81cd

2024-02-13 10:45

dregad


Details Diff
Revert "Fix Error when creating empty RSS feed on PHP 8"

This reverts commit 0e241f33687ce4af5ef483b7f3cbd2ffd8817838.
Affected Issues
0033634
mod - library/README.md Diff File
mod - library/rssbuilder/class.ObjectIterator.inc.php Diff File