User tests: Successful: Unsuccessful:
This Pull Request improves PR #14982.
Check for array to prevent count() warning.
The warning is due to count(false).
Install demo.
In the browser's address bar, enter http://localhost/joomla-cms-staging/archived-articles/2011/1/archives. (replace http://localhost/joomla-cms-staging/ with your domain)
A 404 page is displayed.
Check PHP error log.
no warnings
PHP Warning: count(): Parameter must be an array or an object that implements Countable in \components\com_content\models\category.php on line 457
none
| Status | New | ⇒ | Pending |
| Category | ⇒ | Front End com_content |
| Status | Pending | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-01-17 18:04:48 |
| Closed_By | ⇒ | Quy | |
| Rel_Number | ⇒ | 14982 | |
| Relation Type | ⇒ | Pull Request for |
| Labels |
Added:
?
|
||
| Status | Closed | ⇒ | New |
| Closed_Date | 2018-01-17 18:04:48 | ⇒ | |
| Closed_By | Quy | ⇒ |
| Status | New | ⇒ | Pending |
!$this->_children === null does not execute the if statement at all.
$this->_children !== null always execute even if there are no subcategories.
if ($this->_children !== null)
{
$params = $this->getState()->get('params');
$orderByPri = $params->get('orderby_pri');
if ($orderByPri === 'alpha' || $orderByPri === 'ralpha')
{
$this->_children = ArrayHelper::sortObjects($this->_children, 'title', ($orderByPri === 'alpha') ? 1 : (-1));
}
}
IMO you can use if ($this->_children), count() is not needed. Value of $this->_children could be false, null or array.
I have tested this item
Just a quick note when you are testing on complete new install you need this URL to trigger the error:
http://localhost/{your-path}/index.php/archived-articles/2011/1/archives (adding the index.php)
I have tested this item
| Status | Pending | ⇒ | Ready to Commit |
Ready to Commit after two successful tests.
| Status | Ready to Commit | ⇒ | Fixed in Code Base |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-02-07 00:18:25 |
| Closed_By | ⇒ | zero-24 | |
| Labels |
Added:
?
|
||
Merged Thanks!
See #19216
if (!$categoryId === null)lets do it all the same way