User tests: Successful: Unsuccessful:
This should not generate any PHP warning.
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.
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.
Labels |
Added:
?
|
Rel_Number | ⇒ | 4427 | |
Relation Type | ⇒ | Related to |
Labels |
Added:
?
|
@test It's working :)
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4428.
Status | Pending | ⇒ | Ready to Commit |
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?
Status | Ready to Commit | ⇒ | Information Required |
@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.
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
Agreed. Sounds like a good approach.
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-10-17 14:03:13 |
@success +1
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4428.