PR-5.0-dev Pending

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
25 May 2023

Summary of Changes

This is an idea about what we can do to prevent plugin from booting, when it will not be in use.
Example, when plugin designed to work only for Site or only for Administrator.

When the plugin should not be loaded, the service/provider should return a plugin placeholder.
We already have a class for it called DummyPlugin, so it is not a new feature.

What do you think about it?

Testing Instructions

Apply patch, and check the modified plugins, they should work as before.
For advanced users: dump $dispatcher, to make sure the plugin not loaded when they should not.

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 - 25 May 2023
Category Libraries Front End Plugins
avatar Fedik Fedik - open - 25 May 2023
avatar Fedik Fedik - change - 25 May 2023
Status New Pending
avatar Fedik Fedik - change - 25 May 2023
The description was changed
avatar Fedik Fedik - edited - 25 May 2023
avatar HLeithner
HLeithner - comment - 25 May 2023

I don't like it much, we still have the plugin in our dispatcher, can't we really just not load it? or only load it when it is really triggered based on getEventListners?

avatar Fedik
Fedik - comment - 25 May 2023

we still have the plugin in our dispatcher

Nope, it not there, check it ;)
If you do

dump($dispatcher->getListeners());

You will see that dump() does not contain Dummy Plugins.

can't we really just not load it?

We could return false for $app->bootPlugin() but intrface require to return PluginInterface.

or only load it when it is really triggered based on getEventListners?

First I thought it is a good idea, now after looking around, I think this will not help much.
You see, we still need to query all plugins from DB, and then check them on each Event trigger, whether they are booted or not.
This require rewriting our dispatcher, or have an extra abstraction on top of existing dispatcher, that complicates the logic.
I call this: much hassle, small profit :)

This PR just an idea, that already can work without much investment.
I am not insist on it, maybe we can find some better solution.

Addittionaly I would disable onBeforeExtensionBoot and onAfterExtensionBoot events for Plugins. But that another topic.

avatar laoneo
laoneo - comment - 25 May 2023

Thanks for caring about this issue. The big problem with this approach is that service providers should not contain any logic. Their job is just to provide the services. The logic should be somewhere else. I mean we have a client flag in the db record, perhaps you can use that one much earlier in the life cycle.

avatar Fedik Fedik - change - 26 May 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-05-26 06:53:17
Closed_By Fedik
Labels Added: PR-5.0-dev
avatar Fedik Fedik - close - 26 May 2023

Add a Comment

Login with GitHub to post a comment