From 20cf74aac4de704672f3fe8e156a6b5ad4859730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Thu, 19 Jan 2012 19:17:04 +0100 Subject: [PATCH 1/2] Added some two exceptions : * when java cannot be executed * When execution result_code of yui compressor is not 0 (i.e execution success). --- min/lib/Minify/YUICompressor.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/min/lib/Minify/YUICompressor.php b/min/lib/Minify/YUICompressor.php index cd93b0e..5d6510a 100644 --- a/min/lib/Minify/YUICompressor.php +++ b/min/lib/Minify/YUICompressor.php @@ -90,8 +90,11 @@ class Minify_YUICompressor { throw new Exception('Minify_YUICompressor : could not create temp file.'); } file_put_contents($tmpFile, $content); - exec(self::_getCmd($options, $type, $tmpFile), $output); + exec(self::_getCmd($options, $type, $tmpFile), $output, $result_code); unlink($tmpFile); + if($result_code != 0){ + throw new Exception('Minify_YUICompressor : YUI compressor execution failed.'); + } return implode("\n", $output); } @@ -131,6 +134,9 @@ class Minify_YUICompressor { if (! is_file(self::$jarFile)) { throw new Exception('Minify_YUICompressor : $jarFile('.self::$jarFile.') is not a valid file.'); } + if (! is_executable(self::$jarFile)) { + throw new Exception('Minify_YUICompressor : $jarFile('.self::$jarFile.') is not executable.'); + } if (! is_dir(self::$tempDir)) { throw new Exception('Minify_YUICompressor : $tempDir('.self::$tempDir.') is not a valid direcotry.'); } From b95ce11d4603d7ad9bf6d2d7a9fe3b560f532607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Thu, 19 Jan 2012 19:26:32 +0100 Subject: [PATCH 2/2] Formatting. --- min/lib/Minify/YUICompressor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/min/lib/Minify/YUICompressor.php b/min/lib/Minify/YUICompressor.php index 5d6510a..c5bd8a1 100644 --- a/min/lib/Minify/YUICompressor.php +++ b/min/lib/Minify/YUICompressor.php @@ -92,7 +92,7 @@ class Minify_YUICompressor { file_put_contents($tmpFile, $content); exec(self::_getCmd($options, $type, $tmpFile), $output, $result_code); unlink($tmpFile); - if($result_code != 0){ + if ($result_code != 0) { throw new Exception('Minify_YUICompressor : YUI compressor execution failed.'); } return implode("\n", $output);