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(), 0, 1);
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? ::)
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
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.
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
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.
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
or just get rid of the directory separator with
dirname(__DIR__, 1);