I was testing Simple Portal (development) addon and when uninstalling it I get this error:
The error complains this part of SiteCombiner.class.php:
private function _addFile($options)
{
if (isset($options['dir']))
{
$filename = $options['dir'] . $options['basename'];
$this->_combine_files[$options['basename']] = array(
'file' => $filename,
'basename' => $options['basename'],
'url' => $options['url'],
'filemtime' => filemtime($filename),
'minimized' => (bool) strpos($options['basename'], '.min.js') !== false || strpos($options['basename'], '.min.css') !== false,
);
$this->_stales[] = $this->_combine_files[$options['basename']]['filemtime'];
return true;
}
return false;
}
I read elsewhere where it is suggested to run a check whether $filename exists before continuing with filemtime, otherwise, similar error as above may occur. So I was wondering whether we should add a condition to it to prevent such an error from reoccuring? Is the following way the right way to fix it?
private function _addFile($options)
{
if (isset($options['dir']))
{
$filename = $options['dir'] . $options['basename'];
if (file_exists($filename)) {
$this->_combine_files[$options['basename']] = array(
'file' => $filename,
'basename' => $options['basename'],
'url' => $options['url'],
'filemtime' => filemtime($filename),
'minimized' => (bool) strpos($options['basename'], '.min.js') !== false || strpos($options['basename'], '.min.css') !== false,
);
$this->_stales[] = $this->_combine_files[$options['basename']]['filemtime'];
return true;
}
}
return false;
}