From 0c6936925a988611dca407333424b1b821c50c4a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 14 Jan 2015 21:27:55 +0100 Subject: [PATCH] Added work-around for broken PHP in Plesk 12 on Ubuntu 14.04 --- wcfsetup/install.php | 21 ++++++++++++++++--- .../files/lib/system/io/GZipFile.class.php | 19 +++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install.php b/wcfsetup/install.php index f38adc0423..f4e34d6134 100644 --- a/wcfsetup/install.php +++ b/wcfsetup/install.php @@ -721,6 +721,13 @@ class File { * @author Marcel Werk */ class ZipFile extends File { + /** + * checks if gz*64 functions are available instead of gz* + * https://bugs.php.net/bug.php?id=53829 + * @var boolean + */ + protected static $gzopen64 = null; + /** * Opens a new zipped file. * @@ -728,11 +735,15 @@ class ZipFile extends File { * @param string $mode */ public function __construct($filename, $mode = 'wb') { + if (self::$gzopen64 === null) { + self::$gzopen64 = (function_exists('gzopen64')); + } + $this->filename = $filename; - if (!function_exists('gzopen')) { + if (!self::$gzopen64 && !function_exists('gzopen')) { throw new SystemException('Can not find functions of the zlib extension'); } - $this->resource = @gzopen($filename, $mode); + $this->resource = (self::$gzopen64 ? @gzopen64($filename, $mode) : @gzopen($filename, $mode)); if ($this->resource === false) { throw new SystemException('Can not open file ' . $filename); } @@ -745,7 +756,11 @@ class ZipFile extends File { * @param array $arguments */ public function __call($function, $arguments) { - if (function_exists('gz' . $function)) { + if (self::$gzopen64 && function_exists('gz' . $function . '64')) { + array_unshift($arguments, $this->resource); + return call_user_func_array('gz' . $function . '64', $arguments); + } + else if (function_exists('gz' . $function)) { array_unshift($arguments, $this->resource); return call_user_func_array('gz' . $function, $arguments); } diff --git a/wcfsetup/install/files/lib/system/io/GZipFile.class.php b/wcfsetup/install/files/lib/system/io/GZipFile.class.php index d92b170ec1..2a329200a1 100644 --- a/wcfsetup/install/files/lib/system/io/GZipFile.class.php +++ b/wcfsetup/install/files/lib/system/io/GZipFile.class.php @@ -13,6 +13,13 @@ use wcf\system\exception\SystemException; * @category Community Framework */ class GZipFile extends File { + /** + * checks if gz*64 functions are available instead of gz* + * https://bugs.php.net/bug.php?id=53829 + * @var boolean + */ + protected static $gzopen64 = null; + /** * Opens a gzip file. * @@ -20,8 +27,12 @@ class GZipFile extends File { * @param string $mode */ public function __construct($filename, $mode = 'wb') { + if (self::$gzopen64 === null) { + self::$gzopen64 = (function_exists('gzopen64')); + } + $this->filename = $filename; - $this->resource = gzopen($filename, $mode); + $this->resource = (self::$gzopen64 ? gzopen64($filename, $mode) : gzopen($filename, $mode)); if ($this->resource === false) { throw new SystemException('Can not open file ' . $filename); } @@ -34,7 +45,11 @@ class GZipFile extends File { * @param array $arguments */ public function __call($function, $arguments) { - if (function_exists('gz' . $function)) { + if (self::$gzopen64 && function_exists('gz' . $function . '64')) { + array_unshift($arguments, $this->resource); + return call_user_func_array('gz' . $function . '64', $arguments); + } + else if (function_exists('gz' . $function)) { array_unshift($arguments, $this->resource); return call_user_func_array('gz' . $function, $arguments); } -- 2.20.1