News:

Support the VirtueMart project and become a member

Main Menu

VM creates multiple plugin instances

Started by Ghost, October 25, 2024, 10:32:14 AM

Previous topic - Next topic

Ghost

For modern plugins that use service provider VM creates multiple instances of the plugin. It's causing issues like duplicated HTML in vmcustom plugins, among other things. The problem is coming from this code block https://dev.virtuemart.net/projects/virtuemart/repository/virtuemart/revisions/11044/entry/trunk/virtuemart/administrator/components/com_virtuemart/helpers/vdispatcher.php#L209
Not sure what was the idea here but it will eventually cause even more issues like dependency conflicts. If it needs to return the plugin object, maybe $app->bootPlugin() should be used instead.

VM 4.2.18.11050.

Milbo

Do you mean line 236?

the part line 209 - 226 uses the joomla plugin container and should not create multiple instances.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Ghost

Lines 209-226. I can see the plugin being instantiated at least twice and listeners called even more times. First time it is constructed by Joomla application when plugins are imported using PluginHelper::importPlugin(). This is correct. Then this code registers the plugin and its dependencies again but now with global DIC and returns a new instance. What issue was this code trying solve?