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.0] Recreate namespace map on Joomla! update #36094

Merged

Conversation

joomdonation
Copy link
Contributor

Pull Request for Issue #36089.

Summary of Changes

This PR makes small modification to update Joomla! process so that namespace map is re-generated during Joomla! update. It is needed because when we update to new Joomla version which has new extension added, we need to register namespace of that new extension so that it can work properly.

Testing Instructions

  1. Apply patch from this PR
  2. Download the this update package Joomla_4.1.0-dev+pr.35143-Development-Update_Package.zip. I had to modify original update package for this PR [4.1] [SOC 21] Add a Scheduled Tasks Infrastructure to Joomla #35143 (which introduces new extension for Joomla 4.1) to include the change from this PR so that update process runs smooth.
  3. Go to System -> Update -> Joomla, upload and update your Joomla 4 installation with the above downloaded package. Make sure you do not see any error with the update process.

Actual result BEFORE applying this Pull Request

Without the change from this PR, updating your site to the update package of this PR #35143 will cause a fatal error:

0 Class 'Joomla\Component\Scheduler\Administrator\Extension\SchedulerComponent' not found

Expected result AFTER applying this Pull Request

Update success. Namespace for new extension is successfully registered in administrator/cache/autoload_psr4.php.

Documentation Changes Required

No.

@richard67
Copy link
Member

Added the release blocker label as inherited from the issue.

@bembelimen bembelimen added this to the Joomla 4.0.5 milestone Nov 23, 2021
@bembelimen
Copy link
Contributor

Is a Updater update needed? so if someone updates from 4.0.4 to 4.1 it will still crash?

@laoneo
Copy link
Member

laoneo commented Nov 23, 2021

I would not make a hard reference to the map creator in the model. Instead of listen to the 'onTableAfterStore' event in the plugins/extension/namespacemap/namespacemap.php plugin and recreate the map.

@joomdonation
Copy link
Contributor Author

@bembelimen The modified file is extracted before the request is executed, so the new code will be executed, thus we do not need an update for Updater

@laoneo I don't know how onTableAfterStore helps here. If we want to go with plugin approach, I think we can trigger a new event onJoomlaAfterUpdate (we triggered onJoomlaBeforeUpdate earlier) and add new method to plugins/extension/namespacemap/namespacemap.php to re-create the map.

@laoneo
Copy link
Member

laoneo commented Nov 24, 2021

@joomdonation that sounds even better. As I made a bad experience adding new events to Joomla, I'm a bit hesitant to add a new ones, that's why I didn't suggest that.

@bembelimen
Copy link
Contributor

@bembelimen The modified file is extracted before the request is executed, so the new code will be executed, thus we do not need an update for Updater

Yes, but what happens, if there is a plugin, which uses the new namespaces on a very early trigger (like onAfterInitialize), is this covered?

@joomdonation
Copy link
Contributor Author

joomdonation commented Nov 24, 2021

Yes, but what happens, if there is a plugin, which uses the new namespaces on a very early trigger (like onAfterInitialize), is this covered?

As I understand, that plugin would only run on the next request. In the current request, the new plugin (if added in the update) is not available in database yet, so it is not being executed.

@bembelimen
Copy link
Contributor

I have tested this item ✅ successfully on 1592fc7

For the test scenario you should not patch the base 4.0 version but only the version you're updating to. (it's then like 4.0.4 => 4.1).

But anyways, changes are working for me.


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

@khu5h1
Copy link
Contributor

khu5h1 commented Nov 25, 2021

I have tested this item ✅ successfully on 1592fc7


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

@joomla-cms-bot joomla-cms-bot removed this from the Joomla 4.0.5 milestone Nov 25, 2021
@richard67
Copy link
Member

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Nov 25, 2021
@richard67 richard67 added this to the Joomla 4.0.5 milestone Nov 25, 2021
@wilsonge
Copy link
Contributor

I think not having this in a plugin is probably a good idea here - we don't want any weird issues if we ever namespace the plugin in the future.

@wilsonge wilsonge merged commit d66de71 into joomla:4.0-dev Nov 25, 2021
@wilsonge
Copy link
Contributor

Thanks!

@joomla-cms-bot joomla-cms-bot removed RTC This Pull Request is Ready To Commit labels Nov 25, 2021
@joomdonation joomdonation deleted the recreate_namespace_map_on_joomlaupdate branch November 26, 2021 07:10
@Crisje
Copy link

Crisje commented Mar 10, 2022

hi im having this issue atm and idk what to do, I tried to download the link above but it says not found
please if anyone could help me


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

@joomdonation
Copy link
Contributor Author

@Crisje Delete the file administrator/cache/autoload_psr4.php from your Joomla 4 installation should help solving your issue.

@hjstrauss
Copy link

Thanx @Crisje for your tip that worked for me. But why is this still in 4.1.2 code? I did an update from 4.0.3 to 4.1.2 and ran into this error. Kind regards, HaSTe.


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

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.

9 participants