Feature PR-4.4-dev Pending

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
3 Apr 2023

Summary of Changes

Add deprecation message when plugin use autoloadLanguage = true.
Currently this feature does not allows to use plugins safely, before application initialised, eg onBeforeExecute.
Check:

If everyone agree on it, then I will update all our plugins to use loadLanguage() instead of autoloading.

Testing Instructions

Review should be enough.
Or apply patch and make sure all works as before.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org: IDK
  • No documentation changes for docs.joomla.org needed
  • Pull Request link for manual.joomla.org: IDK
  • No documentation changes for manual.joomla.org needed
avatar joomla-cms-bot joomla-cms-bot - change - 3 Apr 2023
Category Libraries
avatar Fedik Fedik - open - 3 Apr 2023
avatar Fedik Fedik - change - 3 Apr 2023
Status New Pending
avatar Fedik Fedik - change - 3 Apr 2023
The description was changed
avatar Fedik Fedik - edited - 3 Apr 2023
avatar Fedik Fedik - change - 3 Apr 2023
The description was changed
avatar Fedik Fedik - edited - 3 Apr 2023
avatar laoneo
laoneo - comment - 3 Apr 2023

So what should be then the new behavior? That the plugins call loadLanguage by themself at the top of the plugin event function?

avatar Fedik
Fedik - comment - 3 Apr 2023

That the plugins call loadLanguage by themself at the top of the plugin event function?

Yeap, that what I thought. Should not be hard.

avatar laoneo
laoneo - comment - 3 Apr 2023

Would mean when a plugin registers on multiple events which are all called in the same request, the language is loaded multiple times?

avatar Fedik
Fedik - comment - 3 Apr 2023

No, it will load it only once, look:

// If language already loaded, don't load it again.
if ($lang->getPaths($extension)) {
return true;
}

avatar Fedik
Fedik - comment - 3 Apr 2023

Maybe until 6.x we will come up with some smarter idea to load it automatically, without breaking everything :)

avatar laoneo
laoneo - comment - 3 Apr 2023

I have no problem moving it to the event function as constructors should have as less logic as possible and shouldn't do heavy tasks. Especially this one here is usefuel as when the event is not called in a plugin, the language is not called.

avatar laoneo laoneo - change - 6 Apr 2023
Labels Added: PR-4.4-dev
avatar wilsonge
wilsonge - comment - 7 Apr 2023

This is going to seriously break plugins and so we can potentially add new plugins further up in the stack? Sounds odd to me?

avatar Fedik
Fedik - comment - 7 Apr 2023

This is going to seriously break plugins

I do not see it that much critical. Plugin will be able to load language manualy. If they missed it (in J6), then it will be shown untranslated strings. Nothing will explode.

In future (in J 6) it would throw an excaption if someone try to load language before application is initialised.
In any case, the correct language available not early than onAfterRoute event, if I right.

Having it in constructor just not right.

avatar Fedik
Fedik - comment - 10 Apr 2023

I have made alternative #40355 (to 5.0-dev), please review, and choose what is better.

avatar laoneo
laoneo - comment - 3 May 2023

The changes in loadLanguage should be reverted, on some point we want to inject the language directly. Loosens a bit the dependency to the application god object then. The rest looks ok.

avatar Fedik
Fedik - comment - 3 May 2023

Unfortunately we cannot inject Language in to plugin.
The plugins should be able to run at any stage of Application existence, however the language available only "after initialise" stage.

avatar Fedik
Fedik - comment - 3 May 2023

I am closing it in favor of #40355, that introduce zero b.c. break.

avatar Fedik Fedik - close - 3 May 2023
avatar Fedik Fedik - change - 3 May 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-05-03 10:10:59
Closed_By Fedik
Labels Added: Feature

Add a Comment

Login with GitHub to post a comment