Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.2] Remove PHP 5.3 compatibility code in HTMLHelper #37178

Merged
merged 1 commit into from
Mar 7, 2022

Conversation

laoneo
Copy link
Member

@laoneo laoneo commented Mar 2, 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.

@brianteeman
Copy link
Contributor

Technically I suppose this should be deprecated before removal.

@simbus82
Copy link
Contributor

simbus82 commented Mar 3, 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.

@PhilETaylor

This comment was marked as abuse.

@simbus82
Copy link
Contributor

simbus82 commented Mar 4, 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.

@Quy
Copy link
Contributor

Quy commented Mar 4, 2022

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 4, 2022
@roland-d roland-d merged commit a1f517e into joomla:4.2-dev Mar 7, 2022
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 7, 2022
@roland-d
Copy link
Contributor

roland-d commented Mar 7, 2022

Thank you, nice cleanup :)

@roland-d roland-d added this to the Joomla 4.2.0 milestone Mar 7, 2022
@laoneo laoneo deleted the j4/html/helper branch March 8, 2022 05:22
@joomdonation
Copy link
Contributor

@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

@laoneo
Copy link
Member Author

laoneo commented Jun 6, 2022

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

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

@joomdonation
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants