From 01853f7aacde43a071be45d8410b1667905bc878 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 7 Jun 2014 17:48:45 +0700 Subject: [PATCH] Update change log and adjust some coding standards for #261, #265, and #267 --- CHANGELOG.md | 4 +++- src/PhpWord/Autoloader.php | 2 ++ src/PhpWord/Shared/ZipArchive.php | 15 +++++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb0a6c20..a2f52bde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ### Bugfixes -None yet. +- Fix rare PclZip/realpath/PHP version problem - @andrew-kzoo GH-261 ### Deprecated @@ -23,6 +23,8 @@ None yet. ### Miscellaneous - Docs: Add known issue on `README` about requirement for temporary folder to be writable and update `samples/index.php` for this requirement check - @ivanlanin GH-238 +- PclZip: Remove temporary file after used - @andrew-kzoo GH-265 +- Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267 ## 0.11.1 - 2 June 2014 diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index d7e154bb..dbc42187 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -28,6 +28,8 @@ class Autoloader /** * Register * + * @param bool $throw + * @param bool $prepend * @return void */ public static function register($throw = true, $prepend = false) diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 2e6daa13..7515c5b5 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -218,18 +218,21 @@ class ZipArchive { /** @var \PclZip $zip Type hint */ $zip = $this->zip; - $test_filename = realpath($filename); - if($test_filename !== false) { - $filename = $test_filename; + + // Bugfix GH-261 https://github.com/PHPOffice/PHPWord/pull/261 + $realpathFilename = realpath($filename); + if ($realpathFilename !== false) { + $filename = $realpathFilename; } + $filenameParts = pathinfo($filename); $localnameParts = pathinfo($localname); // To Rename the file while adding it to the zip we // need to create a temp file with the correct name - $temp_file = false; + $tempFile = false; if ($filenameParts['basename'] != $localnameParts['basename']) { - $temp_file = true; // temp file created + $tempFile = true; // temp file created $temppath = $this->tempDir . '/' . $localnameParts['basename']; copy($filename, $temppath); $filename = $temppath; @@ -241,7 +244,7 @@ class ZipArchive $res = $zip->add($filename, PCLZIP_OPT_REMOVE_PATH, $pathRemoved, PCLZIP_OPT_ADD_PATH, $pathAdded); - if($temp_file) { + if ($tempFile) { // Remove temp file, if created @unlink($this->tempDir . '/' . $localnameParts["basename"]); }