Added work-around for broken PHP in Plesk 12 on Ubuntu 14.04
authorAlexander Ebert <ebert@woltlab.com>
Wed, 14 Jan 2015 20:27:55 +0000 (21:27 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 14 Jan 2015 20:27:55 +0000 (21:27 +0100)
wcfsetup/install.php
wcfsetup/install/files/lib/system/io/GZipFile.class.php

index f38adc04235bce138b659a818cd05f480be1c8d8..f4e34d61345da1bb640ce829fdf0ddce8bc6f49f 100644 (file)
@@ -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);
                }
index d92b170ec107721388d1b1210e7454609d666d85..2a329200a1d1432341b3e25280d627ce3741aeda 100644 (file)
@@ -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);
                }