diff --git a/index.php b/index.php index 5dc80709..eeecb25c 100644 --- a/index.php +++ b/index.php @@ -461,7 +461,7 @@ public function createBackup(): void { if (!file_exists($backupFolderLocation . '/' . dirname($fileName))) { $state = mkdir($backupFolderLocation . '/' . dirname($fileName), 0750, true); if ($state === false) { - throw new \Exception('Could not create folder: ' . $backupFolderLocation . '/' . dirname($fileName)); + throw new \Exception('Could not create folder: '.$backupFolderLocation.'/'.dirname($fileName)); } } @@ -544,7 +544,7 @@ private function getUpdateServerResponse(): array { /** @var false|string $response */ $response = curl_exec($curl); if ($response === false) { - throw new \Exception('Could not do request to updater server: ' . curl_error($curl)); + throw new \Exception('Could not do request to updater server: '.curl_error($curl)); } curl_close($curl); @@ -737,7 +737,7 @@ private function getVersionByVersionFile(string $versionFile): string { return implode('.', $OC_Version); } - throw new \Exception('OC_Version not found in ' . $versionFile); + throw new \Exception("OC_Version not found in $versionFile"); } /** @@ -754,15 +754,15 @@ public function extractDownload(): void { if ($zipState === true) { $extraction = $zip->extractTo(dirname($downloadedFilePath)); if ($extraction === false) { - throw new \Exception('Error during unpacking zipfile: ' . ($zip->getStatusString())); + throw new \Exception('Error during unpacking zipfile: '.($zip->getStatusString())); } $zip->close(); $state = unlink($downloadedFilePath); if ($state === false) { - throw new \Exception("Could not unlink " . $downloadedFilePath); + throw new \Exception("Can't unlink ". $downloadedFilePath); } } else { - throw new \Exception("Can't handle ZIP file. Error code is: " . print_r($zipState, true)); + throw new \Exception("Can't handle ZIP file. Error code is: ".print_r($zipState, true)); } // Ensure that the downloaded version is not lower @@ -804,7 +804,7 @@ public function replaceEntryPoints(): void { } $state = file_put_contents($this->baseDir . '/../' . $file, $content); if ($state === false) { - throw new \Exception('Can\'t replace entry point: ' . $file); + throw new \Exception('Can\'t replace entry point: '.$file); } } @@ -841,14 +841,10 @@ private function recursiveDelete(string $folder): void { } foreach ($files as $file) { - if (unlink($file) === false) { - throw new \Exception('Could not unlink ' . $file); - } + unlink($file); } foreach ($directories as $dir) { - if (rmdir($dir) === false) { - throw new \Exception('Could not rmdir ' . $dir); - } + rmdir($dir); } $state = rmdir($folder); @@ -937,10 +933,7 @@ public function deleteOldFiles(): void { * @var string $path * @var \SplFileInfo $fileInfo */ - // Build file list first, so the removals won't mess with it - /** @var array */ - $fileList = iterator_to_array($this->getRecursiveDirectoryIterator(), true); - foreach ($fileList as $path => $fileInfo) { + foreach ($this->getRecursiveDirectoryIterator() as $path => $fileInfo) { $currentDir = $this->baseDir . '/../'; $fileName = explode($currentDir, $path)[1]; $folderStructure = explode('/', $fileName, -1); @@ -957,7 +950,7 @@ public function deleteOldFiles(): void { if ($fileInfo->isFile() || $fileInfo->isLink()) { $state = unlink($path); if ($state === false) { - throw new \Exception('Could not unlink: ' . $path); + throw new \Exception('Could not unlink: '.$path); } } elseif ($fileInfo->isDir()) { $state = rmdir($path); @@ -980,10 +973,7 @@ private function moveWithExclusions(string $dataLocation, array $excludedElement * @var string $path * @var \SplFileInfo $fileInfo */ - // Build file list first, so the renames won't mess with it - /** @var array */ - $fileList = iterator_to_array($this->getRecursiveDirectoryIterator($dataLocation), true); - foreach ($fileList as $path => $fileInfo) { + foreach ($this->getRecursiveDirectoryIterator($dataLocation) as $path => $fileInfo) { $fileName = explode($dataLocation, $path)[1]; $folderStructure = explode('/', $fileName, -1); @@ -1064,12 +1054,12 @@ public function finalize(): void { $this->moveWithExclusions($storageLocation, []); $state = rmdir($storageLocation); if ($state === false) { - throw new \Exception('Could not rmdir ' . $storageLocation); + throw new \Exception('Could not rmdir $storagelocation'); } $state = unlink($this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOptionMandatoryString('instanceid') . '/.step'); if ($state === false) { - throw new \Exception('Could not unlink .step'); + throw new \Exception('Could not rmdir .step'); } if (function_exists('opcache_reset')) { @@ -1089,7 +1079,7 @@ private function writeStep(string $state, int $step): void { if (!file_exists($updaterDir)) { $result = mkdir($updaterDir); if ($result === false) { - throw new \Exception('Could not create ' . $updaterDir); + throw new \Exception('Could not create $updaterDir'); } } $result = touch($updaterDir . '/.step'); diff --git a/lib/Updater.php b/lib/Updater.php index 4adc6820..37d112d1 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -423,7 +423,7 @@ public function createBackup(): void { if (!file_exists($backupFolderLocation . '/' . dirname($fileName))) { $state = mkdir($backupFolderLocation . '/' . dirname($fileName), 0750, true); if ($state === false) { - throw new \Exception('Could not create folder: ' . $backupFolderLocation . '/' . dirname($fileName)); + throw new \Exception('Could not create folder: '.$backupFolderLocation.'/'.dirname($fileName)); } } @@ -506,7 +506,7 @@ private function getUpdateServerResponse(): array { /** @var false|string $response */ $response = curl_exec($curl); if ($response === false) { - throw new \Exception('Could not do request to updater server: ' . curl_error($curl)); + throw new \Exception('Could not do request to updater server: '.curl_error($curl)); } curl_close($curl); @@ -699,7 +699,7 @@ private function getVersionByVersionFile(string $versionFile): string { return implode('.', $OC_Version); } - throw new \Exception('OC_Version not found in ' . $versionFile); + throw new \Exception("OC_Version not found in $versionFile"); } /** @@ -716,15 +716,15 @@ public function extractDownload(): void { if ($zipState === true) { $extraction = $zip->extractTo(dirname($downloadedFilePath)); if ($extraction === false) { - throw new \Exception('Error during unpacking zipfile: ' . ($zip->getStatusString())); + throw new \Exception('Error during unpacking zipfile: '.($zip->getStatusString())); } $zip->close(); $state = unlink($downloadedFilePath); if ($state === false) { - throw new \Exception("Could not unlink " . $downloadedFilePath); + throw new \Exception("Can't unlink ". $downloadedFilePath); } } else { - throw new \Exception("Can't handle ZIP file. Error code is: " . print_r($zipState, true)); + throw new \Exception("Can't handle ZIP file. Error code is: ".print_r($zipState, true)); } // Ensure that the downloaded version is not lower @@ -766,7 +766,7 @@ public function replaceEntryPoints(): void { } $state = file_put_contents($this->baseDir . '/../' . $file, $content); if ($state === false) { - throw new \Exception('Can\'t replace entry point: ' . $file); + throw new \Exception('Can\'t replace entry point: '.$file); } } @@ -803,14 +803,10 @@ private function recursiveDelete(string $folder): void { } foreach ($files as $file) { - if (unlink($file) === false) { - throw new \Exception('Could not unlink ' . $file); - } + unlink($file); } foreach ($directories as $dir) { - if (rmdir($dir) === false) { - throw new \Exception('Could not rmdir ' . $dir); - } + rmdir($dir); } $state = rmdir($folder); @@ -899,10 +895,7 @@ public function deleteOldFiles(): void { * @var string $path * @var \SplFileInfo $fileInfo */ - // Build file list first, so the removals won't mess with it - /** @var array */ - $fileList = iterator_to_array($this->getRecursiveDirectoryIterator(), true); - foreach ($fileList as $path => $fileInfo) { + foreach ($this->getRecursiveDirectoryIterator() as $path => $fileInfo) { $currentDir = $this->baseDir . '/../'; $fileName = explode($currentDir, $path)[1]; $folderStructure = explode('/', $fileName, -1); @@ -919,7 +912,7 @@ public function deleteOldFiles(): void { if ($fileInfo->isFile() || $fileInfo->isLink()) { $state = unlink($path); if ($state === false) { - throw new \Exception('Could not unlink: ' . $path); + throw new \Exception('Could not unlink: '.$path); } } elseif ($fileInfo->isDir()) { $state = rmdir($path); @@ -942,10 +935,7 @@ private function moveWithExclusions(string $dataLocation, array $excludedElement * @var string $path * @var \SplFileInfo $fileInfo */ - // Build file list first, so the renames won't mess with it - /** @var array */ - $fileList = iterator_to_array($this->getRecursiveDirectoryIterator($dataLocation), true); - foreach ($fileList as $path => $fileInfo) { + foreach ($this->getRecursiveDirectoryIterator($dataLocation) as $path => $fileInfo) { $fileName = explode($dataLocation, $path)[1]; $folderStructure = explode('/', $fileName, -1); @@ -1026,12 +1016,12 @@ public function finalize(): void { $this->moveWithExclusions($storageLocation, []); $state = rmdir($storageLocation); if ($state === false) { - throw new \Exception('Could not rmdir ' . $storageLocation); + throw new \Exception('Could not rmdir $storagelocation'); } $state = unlink($this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOptionMandatoryString('instanceid') . '/.step'); if ($state === false) { - throw new \Exception('Could not unlink .step'); + throw new \Exception('Could not rmdir .step'); } if (function_exists('opcache_reset')) { @@ -1051,7 +1041,7 @@ private function writeStep(string $state, int $step): void { if (!file_exists($updaterDir)) { $result = mkdir($updaterDir); if ($result === false) { - throw new \Exception('Could not create ' . $updaterDir); + throw new \Exception('Could not create $updaterDir'); } } $result = touch($updaterDir . '/.step'); diff --git a/updater.phar b/updater.phar index d21639a6..ddba9d5c 100755 Binary files a/updater.phar and b/updater.phar differ diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 0c941aa1..a1f1e348 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '14ccc22088938656fb221e3d7f7e8928a58332ab', + 'reference' => 'aac9e4b1f9edc88a0d28dcbfca50276c9a2c25ba', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ '__root__' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '14ccc22088938656fb221e3d7f7e8928a58332ab', + 'reference' => 'aac9e4b1f9edc88a0d28dcbfca50276c9a2c25ba', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),