ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: ahrasis on March 14, 2018, 12:19:44 am

Title: filemtime error in SiteCombiner
Post by: ahrasis on March 14, 2018, 12:19:44 am
I was testing Simple Portal (development) addon and when uninstalling it I get this error:

QuoteWarning: filemtime(): stat failed for
portal.css
/index.php?action=admin;area=packages;sa=uninstall2;package=SimplePortal_ElkArte-development.zip;pid=422
File: /var/www/clients/client2/web14/web/sources/SiteCombiner.class.php
Line: 348

The error complains this part of SiteCombiner.class.php:
Code: [Select]
	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?

Code: [Select]
	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;
}
Title: Re: filemtime error in SiteCombiner
Post by: emanuele on March 19, 2018, 03:41:34 am
Heck I could have added that as well to 1.1.3... oh well, 1.1.4 will be.

Could you please track it at github?
Title: Re: filemtime error in SiteCombiner
Post by: emanuele on March 19, 2018, 06:24:48 pm
Added locally.
Title: Re: filemtime error in SiteCombiner
Post by: ahrasis on March 19, 2018, 07:51:05 pm
I was not sure then, so I posted without tracking it. I will add it in the github then.
Title: Re: filemtime error in SiteCombiner
Post by: emanuele on March 26, 2018, 04:48:53 pm
https://github.com/elkarte/Elkarte/pull/3150/commits/3ed9f35518e4ff700756b2ac413e27bf29ae55da

I went for "add it to minify only if the file exists".