Skip to content

Commit

Permalink
Ignore optimize if cannot write minified files
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhlh committed Jun 19, 2014
1 parent 1257999 commit 009e174
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions source/plg_system_t3/includes/core/minify.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public static function optimizecss($tpl)

if ($stylesheet['mime'] == 'text/css' && ($csspath = self::cssPath($url))) {
$stylesheet['path'] = $csspath;
$stylesheet['data'] = JFile::read($csspath);
$stylesheet['data'] = file_get_contents($csspath);

$selcount = preg_match_all($regex, $stylesheet['data'], $matched);
if(!$selcount) {
Expand Down Expand Up @@ -358,7 +358,10 @@ public static function optimizecss($tpl)
}

$cssdata = implode("\n", $cssdata);
JFile::write($groupfile, $cssdata);
if (!JFile::write($groupfile, $cssdata)) {
// cannot write file, ignore minify
return false;
}
$grouptime = @filemtime($groupfile);
@chmod($groupfile, 0644);
}
Expand Down Expand Up @@ -409,7 +412,7 @@ public static function optimizejs($tpl){
if ($script['mime'] == 'text/javascript' && ($jspath = self::jsPath($url))) {

$script['path'] = $jspath;
$script['data'] = JFile::read($jspath);
$script['data'] = file_get_contents($jspath);

$scripts[$url] = $script;

Expand Down Expand Up @@ -493,7 +496,10 @@ public static function optimizejs($tpl){
}

$jsdata = implode("\n", $jsdata);
JFile::write($groupfile, $jsdata);
if (!JFile::write($groupfile, $jsdata)) {
// cannot write file, ignore optimize
return false;
}
$grouptime = @filemtime($groupfile);
@chmod($groupfile, 0644);
}
Expand Down

0 comments on commit 009e174

Please sign in to comment.