VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: stAn99 on June 01, 2016, 12:36:08 PM

Title: DirectoryIterator::__construct(...): failed to open dir: No such file or direct
Post by: stAn99 on June 01, 2016, 12:36:08 PM
DirectoryIterator::__construct(/web/vm2/mero//test/images/availability/): failed to open dir: No such file or directory

if the directory set up in VM's "General Assets URL" is wrong, it's not possible to visit the Virtuemart configuration backend on joomla 3.5.1 (and possibly other 3.x versions) because JHtml::_('list.images', 'image'.... returns non-recoverable user error if the path does not exists.

To fix this you may need to wrap this code into a try and catch clause:

\administrator\components\com_virtuemart\views\config\tmpl\default_shopfront.php

original code:

echo JHtml::_('list.images', 'image', VmConfig::get('rised_availability'), " ", $this->imagePath);


suggested code:

try
{
echo JHtml::_('list.images', 'image', VmConfig::get('rised_availability'), " ", $this->imagePath);
}
catch (Exception $e)
{
echo '';
}


best regards, stan
Title: Re: DirectoryIterator::__construct(...): failed to open dir: No such file or direct
Post by: Milbo on June 01, 2016, 12:42:00 PM
My current solution, directly in the layout


<?php if(!empty($this->imagePath)) {
echo JHtml::_('list.images''image'VmConfig::get('rised_availability'), " "$this->imagePath);
} else {
echo vmText::_('COM_VIRTUEMART_ADMIN_CFG_ASSETS_GENERAL_PATH_MISSING');
}
?>


Title: Re: DirectoryIterator::__construct(...): failed to open dir: No such file or direct
Post by: Studio 42 on June 01, 2016, 13:48:04 PM
Bug is real, but I tested DirectoryIterator in a search file (with many images), this is 2 to 3 time slower as:
opendir($path)))
      while (($file = readdir ....
So perhaps changing code is better as fix it ?
Title: Re: DirectoryIterator::__construct(...): failed to open dir: No such file or direct
Post by: Milbo on June 01, 2016, 19:53:32 PM
We can do that later, when we use the VMF, but atm it is a joomla function as far as I understood.