VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: kratzi on April 03, 2020, 14:59:37 PM

Title: Cant load 3rd party module after VM upgrade
Post by: kratzi on April 03, 2020, 14:59:37 PM
Hi
I have a strange case here.

Have installed a test environment on J3.9.16 and latest VM 3.6.10

After installation I installed a 3d party component which works fine on the test install.

So I updated my production site to J 3.9.16 and VM 3.6.10 and the 3rd party comp does not load but throws an error under PHP 7.3 like


Warning: require(VMPATH_ADMIN/helpers/vmmodel.php): failed to open stream: No such file or directory in /xxx/administrator/components/com_virtuemart_erp/virtuemart_erp.php on line 24

Warning: require(VMPATH_ADMIN/helpers/vmmodel.php): failed to open stream: No such file or directory in /xxx/administrator/components/com_virtuemart_erp/virtuemart_erp.php on line 24

Fatal error: require(): Failed opening required 'VMPATH_ADMIN/helpers/vmmodel.php' (include_path='.:/usr/share/php:..') in /xxx/administrator/components/com_virtuemart_erp/virtuemart_erp.php on line 24


With PHP 7.4 on the production site the comp does not throw an error but also does not load.

Any suggestions how I could solve this. Why is it working on the test site but when I upgrade my production site it breaks.

Thank you
Title: Re: Cant load 3rd party module after VM upgrade
Post by: Studio 42 on April 03, 2020, 21:49:47 PM
Check if the config is loaded correctly
VMPATH_ADMIN is set only if you load the virtuemart config
This is the standard way to load the config in a component or module in PHP
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT .'/administrator/components/com_virtuemart/helpers/config.php');
VmConfig::loadConfig();
Title: Re: Cant load 3rd party module after VM upgrade
Post by: kratzi on April 03, 2020, 22:32:57 PM
The code looks as following:

//just to load virtuemart constants
require_once JPATH_ADMINISTRATOR.'/components/com_virtuemart/helpers/config.php';

if (!class_exists('VmModel')) require (VMPATH_ADMIN .  '/helpers/vmmodel.php');
if (!class_exists('vRequest')) require (VMPATH_ADMIN .  '/helpers/vrequest.php');


Thank you
Title: Re: Cant load 3rd party module after VM upgrade
Post by: Studio 42 on April 04, 2020, 09:44:11 AM
The code do not set the PATH VMPATH_ADMIN you need to add
VmConfig::loadConfig();



//just to load virtuemart constants
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT .'/administrator/components/com_virtuemart/helpers/config.php');
VmConfig::loadConfig();



All this is already registred when loading the vmConfig

if (!class_exists('VmModel')) require (VMPATH_ADMIN .  '/helpers/vmmodel.php');
if (!class_exists('vRequest')) require (VMPATH_ADMIN .  '/helpers/vrequest.php');


So remove your old code and add my code
Title: Re: Cant load 3rd party module after VM upgrade
Post by: kratzi on April 05, 2020, 01:04:03 AM
Thank you Studio42. This worked well.