User tests: Successful: Unsuccessful:
Removes some PHP 5.3 compatibility code in the HTMLHelper
class. Should probably go into 5.0.
Browse Joomla.
All works.
All works.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Technically I suppose this should be deprecated before removal.
But Joomla 4.x is not compatible with php 5.3: requirements dated August 2021 asks at least php 7.2.5.
If it is an oversight, which had to be solved before the launch of joomla 4.0.x, it could be removed immediately even in the current 4.1.x branch.
Pass by reference has been marked by PHP as deprecated since PHP 5.0.0 !!! This can easily just be removed, especially as Joomla 4 doesn't support PHP 5
I have tested this item
I have tested this item
Tested with PHP 7.3, 7.4, 8.0
Status | Pending | ⇒ | Ready to Commit |
Labels |
Added:
?
|
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-03-07 22:16:10 |
Closed_By | ⇒ | roland-d | |
Labels |
Added:
?
|
Thank you, nice cleanup :)
@roland-d @laoneo This PR might need to be reverted. Otherwise, we would get some warning while calling HTMLHelper methods need to pass parameters by reference. You can test it using this simple code:
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('*')
->from('#__menu')
->where('menutype = '.$db->quote('mainmenu'));
$db->setQuery($query);
$rows = $db->loadObjectList();
$children = [];
// first pass - collect children
foreach ($rows as $v)
{
$pt = $v->parent_id;
$list = @$children[$pt] ? $children[$pt] : [];
array_push($list, $v);
$children[$pt] = $list;
}
$list = HTMLHelper::_('menu.treerecurse', 0, '', [], $children, 9999, 0, 0);
Without this PR, the code works OK. With this PR applied, we are now getting warnings:
Warning: Parameter 4 to Joomla\CMS\HTML\Helpers\Menu::treerecurse() expected to be a reference, value given in D:\www\joomla42\libraries\src\HTML\HTMLHelper.php on line 289
Then this would be correct call when the children array must be a reference:
HTMLHelper::_('menu.treerecurse', 0, '', [], &$children, 9999, 0, 0);
That's not right. You would get the error message like:
Call-time pass-by-reference has been removed in PHP 5.4
. Normally, the method definition will define the pass by reference, when we call the method, we do not need to pass by reference.
Technically I suppose this should be deprecated before removal.