? ? Pending

User tests: Successful: Unsuccessful:

avatar laoneo
laoneo
2 Mar 2022

Summary of Changes

Removes some PHP 5.3 compatibility code in the HTMLHelper class. Should probably go into 5.0.

Testing Instructions

Browse Joomla.

Actual result BEFORE applying this Pull Request

All works.

Expected result AFTER applying this Pull Request

All works.

avatar laoneo laoneo - open - 2 Mar 2022
avatar laoneo laoneo - change - 2 Mar 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 2 Mar 2022
Category Libraries
avatar laoneo laoneo - change - 2 Mar 2022
The description was changed
avatar laoneo laoneo - edited - 2 Mar 2022
avatar brianteeman
brianteeman - comment - 2 Mar 2022

Technically I suppose this should be deprecated before removal.

avatar simbus82
simbus82 - comment - 3 Mar 2022

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.

avatar PhilETaylor
PhilETaylor - comment - 3 Mar 2022

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 successfully on 3a45d9a


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

avatar PhilETaylor PhilETaylor - test_item - 3 Mar 2022 - Tested successfully
avatar simbus82
simbus82 - comment - 4 Mar 2022

I have tested this item successfully on 3a45d9a

Tested with PHP 7.3, 7.4, 8.0


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

avatar simbus82 simbus82 - test_item - 4 Mar 2022 - Tested successfully
avatar Quy Quy - change - 4 Mar 2022
Status Pending Ready to Commit
Labels Added: ?
avatar Quy
Quy - comment - 4 Mar 2022

RTC


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

avatar roland-d roland-d - change - 7 Mar 2022
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: ?
avatar roland-d roland-d - close - 7 Mar 2022
avatar roland-d roland-d - merge - 7 Mar 2022
avatar roland-d
roland-d - comment - 7 Mar 2022

Thank you, nice cleanup :)

avatar joomdonation
joomdonation - comment - 6 Jun 2022

@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

avatar laoneo
laoneo - comment - 6 Jun 2022

Then this would be correct call when the children array must be a reference:

HTMLHelper::_('menu.treerecurse', 0, '', [], &$children, 9999, 0, 0);

avatar joomdonation
joomdonation - comment - 6 Jun 2022

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.

Add a Comment

Login with GitHub to post a comment