VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Lamsds on September 26, 2019, 21:04:52 PM

Title: External export data not work after update VM
Post by: Lamsds on September 26, 2019, 21:04:52 PM
Hi.

I have a problem after update VM 3.4.2 to VM 3.6.2 when using external export of goods. There is an error:

Quote
Joomla\CMS\Form\Form::getInstance() could not load file

I'm using code to connect my script to VM:


<?php
define
('_JEXEC'1);
define('DS'DIRECTORY_SEPARATOR);
define('JPATH_BASE'dirname(__FILE__).DS.'..');

require_once(
JPATH_BASE.DS.'includes'.DS.'defines.php');
require_once(
JPATH_BASE.DS.'includes'.DS.'framework.php');

$app JFactory::getApplication('site');
$app->initialise();

require_once(
JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
require_once(
JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'calculationh.php');

$version = new JVersion();
$version substr($version->getShortVersion(), 01);

VmConfig::loadConfig();

if (
$version == 3) {
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'models'.DS.'product.php');
$model = new VirtueMartModelProduct();
$lang 'uk_ua';
} else {
$lang 'en_gb';
}

$db JFactory::getDBO();

.....................................
.....................................
other construction code
.....................................
.....................................


Think the problem is related to

VmConfig::loadConfig();

What are the possible solutions? ::)

Title: Re: External export data not work after update VM
Post by: StefanSTS on September 27, 2019, 00:33:26 AM
That does not look wrong with VmConfig. I use it without DS though:


if (!class_exists('VmConfig')) {
require(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php');
}
VmConfig::loadConfig();


I have put something like this into my DHL export plugin:

if (file_exists(...some.php) {
    require ...some.php;
} else {
    print an error
}
So you can narrow down on what file was not loaded.

You might want to try to echo your JPATH_BASE first, if you really got the right starting directory.

Stefan
Title: Re: External export data not work after update VM
Post by: Lamsds on September 27, 2019, 08:55:16 AM
My JPATH_BASE and JPATH_ADMINISTRATOR is correct.

On old version 3.4.2 everything works fine.

Something has changed in the new version 3.6 ... and it's not working here.

My script is in the second level directory. When I put the script in the root directory everything works.
Title: Re: External export data not work after update VM
Post by: GJC Web Design on September 27, 2019, 10:43:05 AM
then perhaps VmConfig::loadConfig(); is loading something in VM that is trying to access  Joomla\CMS\Form\Form but from the wrong root ?

But I doubt the construct Joomla\CMS\Form\Form is used in core VM - most (all?) hard references to Joomla having been removed so maybe a 3rd party plugin

try backtracing the calls

blue sky thinking
Title: Re: External export data not work after update VM
Post by: Lamsds on October 03, 2019, 17:47:29 PM
I found a solution for this problem VM after v3.4.5

In my file header

line

define('JPATH_BASE', dirname(__FILE__).DS.'..');

Replace


define('JPATH_BASE', $_SERVER['DOCUMENT_ROOT']);


and line

$version = substr(vmVersion::$RELEASE, 0, 1);

VmConfig::loadConfig();


Replace


VmConfig::loadConfig();
$version = substr(vmVersion::$RELEASE, 0, 1);


Now it works, maybe someone will come in handy too.
Title: Re: External export data not work after update VM
Post by: Studio 42 on October 03, 2019, 22:04:13 PM
define('JPATH_BASE', dirname(__FILE__).DS.'..'); is obsolete
Use
define('JPATH_BASE', dirname(__FILE__).DIRECTORY_SEPARATOR .'..');
DS was a shortcut removed in last Joomla releases


define('JPATH_BASE', $_SERVER['DOCUMENT_ROOT']); do not work if you install Joomla in a subfolder
Title: Re: External export data not work after update VM
Post by: StefanSTS on October 04, 2019, 11:38:25 AM
or just get rid of the directory separator with

dirname(__DIR__, 1);