diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2021-09-07 13:17:46 +0100 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2021-09-07 13:20:27 +0100 |
| commit | 3551ba8d18a97b63dd870fcc9eef3c11b3160913 (patch) | |
| tree | 952305031196365fee155311d76b2ce85c29853b | |
| parent | 6dd2d083e1eae69636456e7a149b48a31147aa3c (diff) | |
| download | webtrees-3551ba8d18a97b63dd870fcc9eef3c11b3160913.tar.gz webtrees-3551ba8d18a97b63dd870fcc9eef3c11b3160913.tar.bz2 webtrees-3551ba8d18a97b63dd870fcc9eef3c11b3160913.zip | |
Fix: closing wrong type of stream
| -rw-r--r-- | app/Services/UpgradeService.php | 17 | ||||
| -rw-r--r-- | phpstan-baseline.neon | 5 |
2 files changed, 14 insertions, 8 deletions
diff --git a/app/Services/UpgradeService.php b/app/Services/UpgradeService.php index 6f37f33a56..c887566b09 100644 --- a/app/Services/UpgradeService.php +++ b/app/Services/UpgradeService.php @@ -37,7 +37,19 @@ use League\Flysystem\ZipArchive\FilesystemZipArchiveProvider; use League\Flysystem\ZipArchive\ZipArchiveAdapter; use ZipArchive; +use function explode; +use function fclose; +use function file_exists; +use function file_put_contents; +use function fopen; +use function ftell; +use function fwrite; use function rewind; +use function unlink; +use function version_compare; + +use const DIRECTORY_SEPARATOR; +use const PHP_VERSION; /** * Automatic upgrades. @@ -149,13 +161,12 @@ class UpgradeService fwrite($tmp, $stream->read(self::READ_BLOCK_SIZE)); if ($this->timeout_service->isTimeNearlyUp()) { + $stream->close(); throw new HttpServerErrorException(I18N::translate('The server’s time limit has been reached.')); } } - if (is_resource($stream)) { - fclose($stream); - } + $stream->close(); // Copy from temporary storage to the file. $bytes = ftell($tmp); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 471d935126..0dcc62b603 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1560,11 +1560,6 @@ parameters: path: app/Services/SiteLogsService.php - - message: "#^Call to function is_resource\\(\\) with Psr\\\\Http\\\\Message\\\\StreamInterface will always evaluate to false\\.$#" - count: 1 - path: app/Services/UpgradeService.php - - - message: "#^Method Fisharebest\\\\Webtrees\\\\Services\\\\UpgradeService\\:\\:downloadFile\\(\\) should return int but returns int\\|false\\.$#" count: 1 path: app/Services/UpgradeService.php |
