joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

[5.2] Move language autoload out from CMSPlugin constructor

Open Fedik opened this issue 1 year ago • 7 comments

Summary of Changes

Alernative to #40309 The patch moves language loading out from CMSPlugin constructor. This makes the constructor lighter and probably esier for tests, also allows to restore #27155.

Testing Instructions

Apply patch, and make sure all works as before. All plugins translated.

Link to documentations

Please select:

  • [ ] Documentation link for docs.joomla.org: IDK
  • [ ] No documentation changes for docs.joomla.org needed
  • [ ] No documentation changes for manual.joomla.org needed
  • [ ] Pull Request link for manual.joomla.org: IDK

Fedik avatar Apr 10 '23 11:04 Fedik

I think it's not a good idea to force the application in the plugin to load the languages, wouldn't it be better to provide the language in the register process?

HLeithner avatar Jul 22 '23 07:07 HLeithner

Accessing language in constructor of the System plugins should be forbiden (and for any other group also). Because the Language available not early than afterInitialise. That will limit the plugin usage, and will not allow to use it for early stages. And this is a main reason why I tries to move language loading out from constructor ;)

Fedik avatar Jul 22 '23 08:07 Fedik

I have tested this item :white_check_mark: successfully on 2bf60900c062f9c38b9a91eb8420c1659bcb5f88

I applied patch, logged in with German selected and opened several plugins - all strings were in German. Is that a valid test?


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

ceford avatar Sep 14 '23 13:09 ceford

I'm not so happy to merge this in to 5.0 anymore, since it would effect existing plugins depending for the loaded language in the constructor. I think we have to postpone this to 6.0 or find a better b/c way.

HLeithner avatar Sep 17 '23 17:09 HLeithner

Yeah, it would be need before first alpha :)

But I thinking to moving it in to bootPlugin(), will be smarter.

if ($plugin->autoloadLanguage()) {
  ... here some code for checking if language is ready, then:  
  $plugin->loadLanguage();
}

For 6 or maybe can get in one of 5.x. Loading language in the plugin constructor is very bad.

Fedik avatar Sep 18 '23 07:09 Fedik

This pull request has been automatically rebased to 5.1-dev.

HLeithner avatar Sep 30 '23 22:09 HLeithner

I have changed approach, should be better now.

Fedik avatar Apr 28 '24 11:04 Fedik

This pull request has been automatically rebased to 5.3-dev.

HLeithner avatar Sep 02 '24 08:09 HLeithner