Feature bug PR-5.0-dev Pending

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
17 Sep 2023

Summary of Changes

Restore array referencing for arguments that was referenced in past. Instead of ArrayProxy.
This applies only for legacy event listeners.
New event listeners should explicitly call $event->updateFoobar($value) to update the argument (only for arguments that expected to be modified).

@HLeithner @wilsonge please review

Testing Instructions

All should work as before.

Actual result BEFORE applying this Pull Request

Works

Expected result AFTER applying this Pull Request

Works

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:
  • No documentation changes for docs.joomla.org needed
  • Pull Request link for manual.joomla.org: joomla/Manual#194
  • No documentation changes for manual.joomla.org needed
avatar joomla-cms-bot joomla-cms-bot - change - 17 Sep 2023
Category Administration com_menus Modules Front End com_contact Libraries
avatar Fedik Fedik - open - 17 Sep 2023
avatar Fedik Fedik - change - 17 Sep 2023
Status New Pending
avatar Fedik Fedik - change - 17 Sep 2023
Title
[5.0] Use array referencing for now
[5.0] Use array referencing for now, for event arguments
avatar Fedik Fedik - edited - 17 Sep 2023
avatar Fedik Fedik - change - 17 Sep 2023
Labels Added: PR-5.0-dev
7847416 17 Sep 2023 avatar Fedik phpcs
avatar Fedik Fedik - change - 17 Sep 2023
The description was changed
avatar Fedik Fedik - edited - 17 Sep 2023
avatar Fedik Fedik - change - 17 Sep 2023
Title
[5.0] Use array referencing for now, for event arguments
[5.0] Restore array referencing for event arguments
avatar Fedik Fedik - edited - 17 Sep 2023
avatar Fedik Fedik - change - 17 Sep 2023
The description was changed
avatar Fedik Fedik - edited - 17 Sep 2023
avatar HLeithner
HLeithner - comment - 17 Sep 2023

thanks, can you do me a favor and add this to the migration documentation with a big note that all events (listed one by one) having references are getting changed in 6.0 and developer need to support the new syntax?

avatar HLeithner HLeithner - close - 17 Sep 2023
avatar HLeithner HLeithner - merge - 17 Sep 2023
avatar HLeithner HLeithner - change - 17 Sep 2023
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-09-17 17:26:56
Closed_By HLeithner
Labels Added: Feature bug
avatar Fedik Fedik - change - 18 Sep 2023
The description was changed
avatar Fedik Fedik - edited - 18 Sep 2023
avatar regularlabs
regularlabs - comment - 17 Oct 2023

A bit late to the party. But there is still a bit of an issue in the ModuleHelper::load method (libraries/src/Helper/ModuleHelper.php).
It Joomla 4 it initially passes the $modules object to the onPrepareModuleList event as null.
This way plugins can see the difference between an unset or an empty module list.

In Joomla 5 however, it is initially set to an empty array. So plugins can no longer tell the difference.

That difference is important!

Say you have 2 plugins that do something on onPrepareModuleList.
Plugin 1 checks stuff and decides the module list should be empty (= no modules should be rendered).
Plugin 2 sees an empty array and says: "Ok, another plugin already decided there are no modules. So we don't have to do anything.

Or:
Plugin 1 checks stuff and decides it should not do anything. So it leaves the $modules as it is (null)
Plugin 2 sees the null value and says: "Ok, we are first to the party. Lets grab the modules we want to push into the $modules list.

Again: no longer possible in Joomla 5.
So now a second plugin would have to override the empty array module list even if a previous module purposely set it that way.

So can the $modules = []; be changed back to $modules = null; in the ModuleHelper::load method?

avatar brianteeman
brianteeman - comment - 17 Oct 2023

@regularlabs better to create a new issue. Not many people look at closed ones

avatar regularlabs
regularlabs - comment - 17 Oct 2023

done
#42149

Add a Comment

Login with GitHub to post a comment