From d62aea20ffc5290ecc721ff034c9c1b727b45351 Mon Sep 17 00:00:00 2001 From: Metallizzer Date: Fri, 12 May 2017 10:18:47 +0700 Subject: [PATCH 1/2] Update AutoUpdate.php http://php.net/manual/en/function.file-get-contents.php "Context" must be passed by the third parameter --- src/AutoUpdate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AutoUpdate.php b/src/AutoUpdate.php index cc8410b..49fd0c4 100755 --- a/src/AutoUpdate.php +++ b/src/AutoUpdate.php @@ -447,7 +447,7 @@ public function checkUpdate() $this->_log->addDebug(sprintf('Get new updates from %s', $updateFile)); // Read update file from update server - $update = @file_get_contents($updateFile, $this->_useBasicAuth()); + $update = @file_get_contents($updateFile, false, $this->_useBasicAuth()); if ($update === false) { $this->_log->addInfo(sprintf('Could not download update file "%s"!', $updateFile)); @@ -552,7 +552,7 @@ public function newVersionAvailable() protected function _downloadUpdate($updateUrl, $updateFile) { $this->_log->addInfo(sprintf('Downloading update "%s" to "%s"', $updateUrl, $updateFile)); - $update = @file_get_contents($updateUrl, $this->_useBasicAuth()); + $update = @file_get_contents($updateUrl, false, $this->_useBasicAuth()); if ($update === false) { $this->_log->addError(sprintf('Could not download update "%s"!', $updateUrl)); From 2e8d76885cc44ea1802b2909130e5baa63db4f7c Mon Sep 17 00:00:00 2001 From: Metallizzer Date: Tue, 23 May 2017 19:28:47 +0700 Subject: [PATCH 2/2] Update AutoUpdate.php fwrite() returns the number of bytes written, or FALSE on error. --- src/AutoUpdate.php | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/AutoUpdate.php b/src/AutoUpdate.php index 49fd0c4..cb6ea6a 100755 --- a/src/AutoUpdate.php +++ b/src/AutoUpdate.php @@ -759,7 +759,7 @@ protected function _install($updateFile, $simulateInstall, $version) } else { // touch will fail if PHP is not the owner of the file, and file_put_contents is faster than touch. if (file_put_contents($absoluteFilename, '') === false) { - $this->_log->addError(sprintf('[SIMULATE] The file "%s" could not be created!', $absoluteFilename)); + $this->_log->addError(sprintf('The file "%s" could not be created!', $absoluteFilename)); zip_close($zip); return false; @@ -778,21 +778,10 @@ protected function _install($updateFile, $simulateInstall, $version) } - if (!fwrite($updateHandle, $contents)) { - if (zip_entry_filesize($file) == 0) { - if (!file_put_contents($absoluteFilename , chr(0) )) { - - $this->_log->addError(sprintf('Could not write to file "%s"!', $absoluteFilename)); - zip_close($zip); - return false; - } - } - else - { - $this->_log->addError(sprintf('Could not write to file "%s"!', $absoluteFilename)); - zip_close($zip); - return false; - } + if (false === fwrite($updateHandle, $contents)) { + $this->_log->addError(sprintf('Could not write to file "%s"!', $absoluteFilename)); + zip_close($zip); + return false; } fclose($updateHandle);