From: Alexander Ebert Date: Wed, 14 Jan 2015 14:48:51 +0000 (+0100) Subject: Added work-around for broken PHP in Plesk 12 on Ubuntu 14.04 X-Git-Tag: 2.1.0_Beta_4~99 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=eedfeca6aa6e72442e9e0837ebcd5bb1cbc274ca;p=GitHub%2FWoltLab%2FWCF.git Added work-around for broken PHP in Plesk 12 on Ubuntu 14.04 --- diff --git a/wcfsetup/install.php b/wcfsetup/install.php index f7f0809db2..6965224d79 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 3589a4cc41..5cbf8a6ad9 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); }