From 3fbe07078fa57abe82b9584e11075a83ce15265a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 4 Jun 2012 19:54:01 -0700 Subject: Second attempt to fix #1821 - first attempt caused an infinite loop in some cases when zlib.output_compression is enabled. --- modules/gallery/controllers/file_proxy.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules/gallery/controllers/file_proxy.php') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 36c6bc2a..47def436 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -128,7 +128,12 @@ class File_Proxy_Controller extends Controller { // going to buffer up whatever file we're proxying (and it may be very large). This may // affect embedding or systems with PHP's output_buffering enabled. while (ob_get_level()) { - ob_end_clean(); + Kohana_Log::add("error","".print_r(ob_get_level(),1)); + if (!@ob_end_clean()) { + // ob_end_clean() can return false if the buffer can't be removed for some reason + // (zlib output compression buffers sometimes cause problems). + break; + } } readfile($file); -- cgit v1.2.3 From 6fbea19b352f880a6241dd359336ace5a4f26d22 Mon Sep 17 00:00:00 2001 From: Tony Fung Date: Tue, 5 Jun 2012 11:16:37 +0800 Subject: Force Turn off the compress as most image file already compressed. --- modules/gallery/controllers/file_proxy.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules/gallery/controllers/file_proxy.php') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 47def436..6c5419e8 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -29,6 +29,12 @@ class File_Proxy_Controller extends Controller { const ALLOW_PRIVATE_GALLERY = true; public function __call($function, $args) { + + // Force Turn off the compress as most image file already compressed. + // And the compress will slow down the response. + if(ini_get('zlib.output_compression')) + ini_set('zlib.output_compression', 'Off'); + // request_uri: gallery3/var/albums/foo/bar.jpg?m=1234 $request_uri = rawurldecode(Input::instance()->server("REQUEST_URI")); -- cgit v1.2.3 From 9e1f975e7bdd68d80492d418ad908d1367923aaa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 5 Jun 2012 14:08:15 -0700 Subject: Fix up syntax in the last change. Follow-on for #1879. --- modules/gallery/controllers/file_proxy.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'modules/gallery/controllers/file_proxy.php') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 6c5419e8..49aa9c5a 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -29,12 +29,13 @@ class File_Proxy_Controller extends Controller { const ALLOW_PRIVATE_GALLERY = true; public function __call($function, $args) { - - // Force Turn off the compress as most image file already compressed. - // And the compress will slow down the response. - if(ini_get('zlib.output_compression')) - ini_set('zlib.output_compression', 'Off'); - + + // Force zlib compression off. Image and movie files are already compressed and + // recompressing them is CPU intensive. + if (ini_get("zlib.output_compression")) { + ini_set("zlib.output_compression", "Off"); + } + // request_uri: gallery3/var/albums/foo/bar.jpg?m=1234 $request_uri = rawurldecode(Input::instance()->server("REQUEST_URI")); -- cgit v1.2.3