? Success
Related to # 4427

User tests: Successful: Unsuccessful:

avatar jissereitsma
jissereitsma
2 Oct 2014

Steps to reproduce the issue

  • Enable PHP error reporting in your webserver
  • Create an empty Joomla category with no articles
  • Access this Joomla category URL in your browser - it should display no articles
  • Append ?format=feed&type=rss to this URL

Expected result

This should not generate any PHP warning.

Actual result

This should generate a PHP warning in either your browser or in your PHP error_log. The problem is that the PHP code loops through a $this->items array without checking whether this array is actually empty or not.

Additional comments

GitHub pull request will come right after submitting the issue. The pull request will simply add a if-check around the foreach-loop to prevent the PHP warning.

avatar jissereitsma jissereitsma - open - 2 Oct 2014
avatar jissues-bot jissues-bot - change - 2 Oct 2014
Labels Added: ?
avatar brianteeman brianteeman - change - 4 Oct 2014
Rel_Number 4427
Relation Type Related to
avatar nicksavov nicksavov - change - 16 Oct 2014
Labels Added: ?
avatar brianteeman brianteeman - change - 17 Oct 2014
The description was changed
avatar tairedweb tairedweb - test_item - 17 Oct 2014 - Tested successfully
avatar tairedweb
tairedweb - comment - 17 Oct 2014

@success +1
screen shot 2014-10-17 at 02 15 12

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4428.

avatar luredweb
luredweb - comment - 17 Oct 2014

@test It's working :)

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4428.

avatar luredweb luredweb - test_item - 17 Oct 2014 - Tested successfully
avatar brianteeman brianteeman - change - 17 Oct 2014
Status Pending Ready to Commit
avatar Bakual
Bakual - comment - 17 Oct 2014

I can't reproduce this warning. And looking at the code, I would also not expect a warning.

If there are no articles, $items is an empty array. Using foreach with an empty array is absolutely fine and shouldn't trigger any warning.

@jissereitsma How did you get the warning you try to solve? Can you post the actual warning you got?

avatar Bakual Bakual - change - 17 Oct 2014
Status Ready to Commit Information Required
avatar jissereitsma
jissereitsma - comment - 17 Oct 2014

@Bakual Only if $items is null (and not just an empty array), the foreach() structure will trigger a PHP error. Just to make sure this PHP error is there, error reporting needs to be configured to "maximum" within the Global Configuration.

I tested this now with the current core, and indeed the $items is always an array. Debugging the code brings me back to the JModelList class which contains a getItems() method which always returns a valid list (database result, so an array) unless there is an invalid cache available. So currently I'm unable to reproduce the original issue (mainly because I don't have access to the original site), however there is still a "theoretical possibiility" of this error occurring. I'll dive deeper.

avatar Bakual
Bakual - comment - 17 Oct 2014

Yep, if it's null, then a warning will be triggered. But this should never happen. Imho, if you get null, then the bug should be fixed where that is generated and make it an empty array instead :smile:

avatar jissereitsma
jissereitsma - comment - 17 Oct 2014

Agreed. Sounds like a good approach.

avatar jissereitsma jissereitsma - close - 17 Oct 2014
avatar jissereitsma jissereitsma - change - 17 Oct 2014
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2014-10-17 14:03:13

Add a Comment

Login with GitHub to post a comment