Skip to content

Commit

Permalink
Update AutoUpdate.php
Browse files Browse the repository at this point in the history
fwrite() returns the number of bytes written, or FALSE on error.
  • Loading branch information
Metallizzer committed May 23, 2017
1 parent d62aea2 commit 2e8d768
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/AutoUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 2e8d768

Please sign in to comment.