From 44f8668c92745b448166b8770429f47001ab1efa Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Wed, 8 Oct 2008 14:20:34 +0000 Subject: [PATCH] Issue 60. Zlib no longer required, but unit tests gives a "WARN" that encoding will not be performed. --- min/lib/Minify.php | 6 ++++-- min/lib/Minify/Controller/Base.php | 2 +- min_unit_tests/test_HTTP_Encoder.php | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/min/lib/Minify.php b/min/lib/Minify.php index 4762c6f..5ab651c 100644 --- a/min/lib/Minify.php +++ b/min/lib/Minify.php @@ -263,8 +263,10 @@ class Minify { // generate & cache content $content = self::_combineMinify(); self::$_cache->store($cacheId, $content); - self::$_cache->store($cacheId . '.zd', gzdeflate($content, self::$_options['encodeLevel'])); - self::$_cache->store($cacheId . '.zg', gzencode($content, self::$_options['encodeLevel'])); + if (function_exists('gzdeflate')) { + self::$_cache->store($cacheId . '.zd', gzdeflate($content, self::$_options['encodeLevel'])); + self::$_cache->store($cacheId . '.zg', gzencode($content, self::$_options['encodeLevel'])); + } } } else { // no cache diff --git a/min/lib/Minify/Controller/Base.php b/min/lib/Minify/Controller/Base.php index 0d40c96..2622d2c 100644 --- a/min/lib/Minify/Controller/Base.php +++ b/min/lib/Minify/Controller/Base.php @@ -43,7 +43,7 @@ abstract class Minify_Controller_Base { public function getDefaultMinifyOptions() { return array( 'isPublic' => true - ,'encodeOutput' => true + ,'encodeOutput' => function_exists('gzdeflate') ,'encodeMethod' => null // determine later ,'encodeLevel' => 9 ,'minifierOptions' => array() // no minifier options diff --git a/min_unit_tests/test_HTTP_Encoder.php b/min_unit_tests/test_HTTP_Encoder.php index 81a85fa..05a03b7 100644 --- a/min_unit_tests/test_HTTP_Encoder.php +++ b/min_unit_tests/test_HTTP_Encoder.php @@ -88,6 +88,11 @@ function test_HTTP_Encoder() } } + if (! function_exists('gzdeflate')) { + echo "!WARN: HTTP_Encoder : Zlib support is not present in PHP. Encoding cannot be performed/tested.\n"; + return; + } + // test compression of varied content (HTML,JS, & CSS) $variedContent = file_get_contents($thisDir . '/_test_files/html/before.html') . file_get_contents($thisDir . '/_test_files/css/subsilver.css')