Fixed unpack() to support PHP 5.5
authorAlexander Ebert <ebert@woltlab.com>
Wed, 3 Jul 2013 12:22:30 +0000 (14:22 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 3 Jul 2013 12:22:30 +0000 (14:22 +0200)
wcfsetup/install.php
wcfsetup/install/files/lib/system/io/Tar.class.php

index 57ba997bc27e25d57b19ca13d2a9f27a5801e43f..13a34bc15a28b90267372f8f0582fc7ec5dc8d2e 100644 (file)
@@ -615,7 +615,14 @@ class Tar {
 
                // Extract the values
                //$data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $binaryData);
-               $data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix", $binaryData);
+               if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
+                       $format = 'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor/Z155prefix';
+               }
+               else {
+                       $format = 'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix';
+               }
+               
+               $data = unpack($format, $binaryData);
                
                // Extract the properties
                $header['checksum'] = octDec(trim($data['checksum']));
index 19b8a8ac3a74941f5833145adf52edb76aa1f710..a73fed4548a79979d39abedcd00678707241c9ed 100644 (file)
@@ -264,7 +264,14 @@ class Tar implements IArchive {
                                $longFilename = null;
                        }
                        if ($header['typeflag'] == 'L') {
-                               $fileData = unpack("a".$header['size']."filename", $this->file->read(512));
+                               if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
+                                       $format = 'Z'.$header['size'].'filename';
+                               }
+                               else {
+                                       $format = 'a'.$header['size'].'filename';
+                               }
+                               
+                               $fileData = unpack($format, $this->file->read(512));
                                $longFilename = $fileData['filename'];
                                $header['size'] = 0;
                        }
@@ -307,7 +314,14 @@ class Tar implements IArchive {
                }
                
                // extract values
-               $data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix", $binaryData);
+               if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
+                       $format = 'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor/Z155prefix';
+               }
+               else {
+                       $format = 'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix';
+               }
+               
+               $data = unpack($format, $binaryData);
                
                // Extract the properties
                $header['checksum'] = octDec(trim($data['checksum']));