From: vincent@cubedesigners.com Date: Thu, 22 Feb 2018 15:58:41 +0000 (+0000) Subject: fix #1959 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=4d8bb3d36623556a14db9e14d3a0a1d3752b4ec7;p=cubeextranet.git fix #1959 @0.5 --- diff --git a/inc/ws/Util/class.ws.tools.php b/inc/ws/Util/class.ws.tools.php index 139d21be2..498a4dd73 100644 --- a/inc/ws/Util/class.ws.tools.php +++ b/inc/ws/Util/class.ws.tools.php @@ -144,17 +144,44 @@ class wsTools { return 'doesnt exists'; } + $baseoptimized = str_replace('%s', '', $optimized); + + $notexists = !file_exists($baseoptimized); + if (!$notexists) { + $cleanerexpired = filemtime($baseoptimized) < filemtime('/usr/local/bin/svgcleaner'); + $originalexpired = filemtime($baseoptimized) < filemtime($original); + } else { + $cleanerexpired = false; + $originalexpired = false; + } + $optimize = $force || - !file_exists($optimized) || - filemtime($optimized) < filemtime('/usr/local/bin/svgcleaner') || - filemtime($optimized) < filemtime($original); + $notexists || + $cleanerexpired || + $originalexpired; + + if ($force) { + trigger_error('optimizeSVG forced'); + } + if ($notexists) { + trigger_error('optimizeSVG not exists'); + } + if ($cleanerexpired) { + trigger_error('optimizeSVG cleaner expired'); + } + if ($originalexpired) { + trigger_error('optimizeSVG original expired'); + } if ($optimize) { - $cmd = "/usr/local/bin/svgcleaner --allow-bigger-file --paths-coordinates-precision 3 --copy-on-error --stdout $original"; + $cmd = "timeout -s 1 2 /usr/local/bin/svgcleaner --allow-bigger-file --paths-coordinates-precision 3 --copy-on-error --stdout $original"; $svg = `$cmd`; + if ($svg == '') { + $svg = file_get_contents($original); + } $svg = substr_replace($svg, 'preserveAspectRatio="none" ', 5, 0); - $fname = str_replace('%s', '', $optimized); + $fname = $baseoptimized; file_put_contents($fname, $svg); if (count($resolutions) > 0) { @@ -170,7 +197,7 @@ class wsTools { } public static function optimizeRaster($matches) { - + return ''; } diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 24e639e2d..9e48fd8d3 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -261,7 +261,6 @@ class wsHTML5Compiler { } $time = $currenttime - $this->logtime; $log = $step . ' | ' . round($time, 3) . 's' . "\n"; - $log = $step . ' | ' . round($time, 3) . 's' . "\n"; fwrite($this->logfp, $log); fflush($this->logfp); $this->logtime = $currenttime; @@ -1208,7 +1207,6 @@ class wsHTML5Compiler { wsTools::optimizeSVG($orig, $opt); wsTools::optimizeSVG($full, $fullopt, [150, 300]); - if (in_array($page, $this->config->vectorPages)) { $this->vdir->copy(str_replace('%s', '-150', $fullopt), 'data/contents/p' . $page . '.svg'); } else {