Since Joomla 3.7 the Joomla plugin updater appears to try to load a plugin before a plugin update is executed (so a possible trigger onInstallerBeforePackageDownload is available). This is done in administrator/components/com_installer/models/update.php, function preparePreUpdate.
Whenever the plugin is updated through the plugin updater, it is now explicitly loaded by a call to JPluginHelper::importPlugin. Unfortunately, only the plugin is loaded, not the whole VM environment apparently. All VM plugins are loaded from within VM, so all these plugins assume VM is already properly setup.
In particular, all shipping and payment plugins I have seen simply start like:
<?php
defined ('_JEXEC') or die('Restricted access');
if (!class_exists ('vmPSPlugin')) {
require(JPATH_VM_PLUGINS . DS . 'vmpsplugin.php');
}
[...]
This will fail with an error message when the plugin is updated through the Joomla plugin updater:
Notice: Use of undefined constant JPATH_VM_PLUGINS - assumed 'JPATH_VM_PLUGINS' in /var/www/html/plugins/vmshipment/rules_shipping_advanced/rules_shipping_advanced.php on line 23
Notice: Use of undefined constant DS - assumed 'DS' in /var/www/html/plugins/vmshipment/rules_shipping_advanced/rules_shipping_advanced.php on line 23
Warning: require(JPATH_VM_PLUGINSDSvmpsplugin.php): failed to open stream: No such file or directory in /var/www/html/plugins/vmshipment/rules_shipping_advanced/rules_shipping_advanced.php on line 23
Fatal error: require(): Failed opening required 'JPATH_VM_PLUGINSDSvmpsplugin.php' (include_path='.:/usr/local/lib/php') in /var/www/html/plugins/vmshipment/rules_shipping_advanced/rules_shipping_advanced.php on line 23
Manually installing the .zip file of the new version works fine to update the plugin, but the Joomla plugin updater (which is now more or less forced by the JED) triggers this problem.
What is the proper way to ensure VM is fully loaded in a plugin, so that a JPluginHelper::importPlugin call on a plugin works?
Thanks,
Reinhold