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
COM_AJAX: plugins are loaded wrong way #17955
Comments
You're getting these errors because VmConfig isn't loaded. VM plugins assume it would be loaded (they're not designed to be used outside of VM). VM recently added a system plugin which loads VmConfig but only on Joomla updater pages. You could ask VM developer to add AJAX page support or make your own plugin. |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/17955 |
as stated above closed as no Core-Issue. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17955. |
@SharkyKZ its not just about VM plugin. on the other hand - for now i cant assign a plugin into 2 or more different groups - i would do it, just to make it support ajax, but joomla is not flexible enough so basically you ask me to find workaround for this case and do not use built-in ajax functions. resuming: for now built-in ajax requires all the plugins of a custom group (not "ajax" one) to be written with ajax support (meaning: not having errors when loaded with plugin loader). thats not how you develop stuff, its just totally wrong. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17955. |
First, let me clarify that the There is no API to load a single specific plugin. The plugin architecture doesn't work that way (and should not). The issue you have is not related to how com_ajax works. It's related to how the vm plugins are written. If they would first check if VmConfig is loaded (which would be good practice), then that issue wouldn't exist. |
@Bakual so, in other words, parameter "plugin" it not the parameter "plugin" and should be renamed into "eventName" or just "event". edit: the part about "not enough checks in 3-rd party plugins" - so true. |
From todays point of view, it's not named ideally. Back then, there was no
Yes, any loaded plugin can respond to it. It's not even restricted to plugins of the specified group. I think at least system plugins are loaded as well at this point. |
naming stuff is the second hardest thing in development. (and every joke has a bit of joke.)
thats very cute when people follow the patterns ). let i describe another way: now keeping in mind - i talk about ajax stuff (not regular frontend) so there are 2 ways to create response in backend :
this issues is about 2-nd part - framework can not resolve dependency and load VM core before plugin because it does not know how to do it. since devs can write plugins depending on modules which depend on components depending on another components - there should be framework dependency resolver, which helps to load all the dependency tree before it starts to create the response in a plugin. as i can see - it is not handled in this way, it's not dependency resolver, it's event based system. i have worked with systems which follow case 1 - slower but i get what i want and not trying to workaround native stuff. |
Just to be clear, I'm not disagreeing, I just wanted to point out you were getting errors because of VM. As others have said, making a change here could be a B/C break. But a parameter to import only single specified plugin can be added without trouble. |
Here is the code in com_ajax/ajax.php
what does it do : gets plugins' group from URL and loads it. then it emits an event.
whats wrong with that:
so in the end i get fatal error : undefined constants (DS) and (JPATH_VM_PLUGINS)
this happens just because loading logic is wrong: the com_ajax code loads all the plugins of a group at once and try to emit an event for all of them.
instead, i expected only MYPLUGIN to be loaded.
and that is achieved just by adding some code in importPlugin call like this:
this loads only my plugin and nothing else (or all the group, if 'plugin' key not found in $input, because the default is 'null')
==============
here are some errors produced during the ajax call
Notice: Use of undefined constant JPATH_VM_PLUGINS - assumed 'JPATH_VM_PLUGINS' in ****/plugins/vmshipment/weight_countries/weight_countries.php on line 24
Notice: Use of undefined constant DS - assumed 'DS' in ****/plugins/vmshipment/weight_countries/weight_countries.php on line 24
Warning: require(JPATH_VM_PLUGINSDSvmpsplugin.php): failed to open stream: No such file or directory in ****/plugins/vmshipment/weight_countries/weight_countries.php on line 24
Warning: require(JPATH_VM_PLUGINSDSvmpsplugin.php): failed to open stream: No such file or directory in ****/plugins/vmshipment/weight_countries/weight_countries.php on line 24
Fatal error: require(): Failed opening required 'JPATH_VM_PLUGINSDSvmpsplugin.php' (include_path='.:/opt/php56/share/pear:/opt/php56/share/php/php') in ****/plugins/vmshipment/weight_countries/weight_countries.php on line 24
The text was updated successfully, but these errors were encountered: