From 4a3d66bc75a7654dc72611b227b088aa8a995408 Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Thu, 11 Mar 2021 12:21:33 +0000 Subject: [PATCH] Remove vendor dir, add support for PHP 8.0, drop support for PHP 7.1 and 7.2 --- app/Factories/ImageFactory.php | 12 +++++++----- app/Http/RequestHandlers/EditMediaFileAction.php | 3 +-- app/Http/RequestHandlers/ManageMediaData.php | 3 ++- app/Services/ServerCheckService.php | 3 +-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/Factories/ImageFactory.php b/app/Factories/ImageFactory.php index 0fef92eb790..5dda4f8b6b0 100644 --- a/app/Factories/ImageFactory.php +++ b/app/Factories/ImageFactory.php @@ -34,6 +34,7 @@ use Intervention\Image\ImageManager; use League\Flysystem\FilesystemException; use League\Flysystem\FilesystemOperator; +use League\Flysystem\UnableToReadFile; use Psr\Http\Message\ResponseInterface; use RuntimeException; use Throwable; @@ -41,6 +42,7 @@ use function addcslashes; use function basename; use function extension_loaded; +use function get_class; use function pathinfo; use function response; use function strlen; @@ -132,11 +134,11 @@ public function thumbnailResponse( return $this->imageResponse($data, $image->mime(), ''); } catch (NotReadableException $ex) { return $this->replacementImageResponse('.' . pathinfo($path, PATHINFO_EXTENSION)); - } catch (FileNotFoundException $ex) { + } catch (UnableToReadFile $ex) { return $this->replacementImageResponse((string) StatusCodeInterface::STATUS_NOT_FOUND); } catch (Throwable $ex) { return $this->replacementImageResponse((string) StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR) - ->withHeader('X-Thumbnail-Exception', $ex->getMessage()); + ->withHeader('X-Thumbnail-Exception', basename(get_class($ex)) . ': ' . $ex->getMessage()); } } @@ -176,7 +178,7 @@ public function mediaFileResponse(MediaFile $media_file, bool $add_watermark, bo } catch (NotReadableException $ex) { return $this->replacementImageResponse(pathinfo($filename, PATHINFO_EXTENSION)) ->withHeader('X-Image-Exception', $ex->getMessage()); - } catch (FileNotFoundException $ex) { + } catch (UnableToReadFile $ex) { return $this->replacementImageResponse((string) StatusCodeInterface::STATUS_NOT_FOUND); } catch (Throwable $ex) { return $this->replacementImageResponse((string) StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR) @@ -244,11 +246,11 @@ public function mediaFileThumbnailResponse( return $this->imageResponse($data, $mime_type, ''); } catch (NotReadableException $ex) { return $this->replacementImageResponse('.' . pathinfo($path, PATHINFO_EXTENSION)); - } catch (FileNotFoundException $ex) { + } catch (UnableToReadFile $ex) { return $this->replacementImageResponse((string) StatusCodeInterface::STATUS_NOT_FOUND); } catch (Throwable $ex) { return $this->replacementImageResponse((string) StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR) - ->withHeader('X-Thumbnail-Exception', $ex->getMessage()); + ->withHeader('X-Thumbnail-Exception', basename(get_class($ex)) . ': ' . $ex->getMessage()); } } diff --git a/app/Http/RequestHandlers/EditMediaFileAction.php b/app/Http/RequestHandlers/EditMediaFileAction.php index e40556d72ea..c52924e52e6 100644 --- a/app/Http/RequestHandlers/EditMediaFileAction.php +++ b/app/Http/RequestHandlers/EditMediaFileAction.php @@ -27,8 +27,7 @@ use Fisharebest\Webtrees\Services\MediaFileService; use Fisharebest\Webtrees\Services\PendingChangesService; use Fisharebest\Webtrees\Tree; -use League\Flysystem\FileExistsException; -use League\Flysystem\FileNotFoundException; +use League\Flysystem\UnableToReadFile; use League\Flysystem\FilesystemException; use League\Flysystem\UnableToMoveFile; use League\Flysystem\Util; diff --git a/app/Http/RequestHandlers/ManageMediaData.php b/app/Http/RequestHandlers/ManageMediaData.php index edacbb208b7..2f25eefc371 100644 --- a/app/Http/RequestHandlers/ManageMediaData.php +++ b/app/Http/RequestHandlers/ManageMediaData.php @@ -32,6 +32,7 @@ use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use League\Flysystem\FilesystemOperator; +use League\Flysystem\UnableToReadFile; use League\Flysystem\UnableToRetrieveMetadata; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -128,7 +129,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface $url = route(AdminMediaFileDownload::class, ['path' => $path]); $img = '' . $img . ''; - } catch (FileNotFoundException $ex) { + } catch (UnableToReadFile $ex) { $url = route(AdminMediaFileThumbnail::class, ['path' => $path]); $img = ''; } diff --git a/app/Services/ServerCheckService.php b/app/Services/ServerCheckService.php index c46f7aa3bcd..07c8a8cf191 100644 --- a/app/Services/ServerCheckService.php +++ b/app/Services/ServerCheckService.php @@ -51,10 +51,9 @@ class ServerCheckService private const PHP_SUPPORT_URL = 'https://www.php.net/supported-versions.php'; private const PHP_MINOR_VERSION = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION; private const PHP_SUPPORT_DATES = [ - '7.1' => '2019-12-01', - '7.2' => '2020-11-30', '7.3' => '2021-12-06', '7.4' => '2022-11-28', + '8.0' => '2023-11-26', ]; // As required by illuminate/database 5.8