From fa7553cf0e45d4189baadf7404299c81377e36ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 4 Aug 2020 10:29:28 +0200 Subject: [PATCH] Make use of ImageAdapter::checkMemoryLimit() --- .../upload/DefaultUploadFileSaveStrategy.class.php | 9 +++++---- .../UserCoverPhotoUploadFileValidationStrategy.class.php | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php b/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php index 3933798573..644a135b9f 100644 --- a/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php +++ b/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php @@ -177,15 +177,15 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy { $object = $parameters['object']; } + $adapter = ImageHandler::getInstance()->getAdapter(); // rotate image based on the exif data if (!empty($this->options['rotateImages'])) { if ($object->isImage) { - if (FileUtil::checkMemoryLimit($object->width * $object->height * ($object->fileType == 'image/png' ? 4 : 3) * 2.1)) { + if ($adapter->checkMemoryLimit($object->width, $object->height, $object->fileType)) { $exifData = ExifUtil::getExifData($object->getLocation()); if (!empty($exifData)) { $orientation = ExifUtil::getOrientation($exifData); if ($orientation != ExifUtil::ORIENTATION_ORIGINAL) { - $adapter = ImageHandler::getInstance()->getAdapter(); $adapter->loadFile($object->getLocation()); $newImage = null; @@ -292,12 +292,13 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy { return; } + $adapter = ImageHandler::getInstance()->getAdapter(); + // check memory limit - if (!FileUtil::checkMemoryLimit($file->width * $file->height * ($file->fileType == 'image/png' ? 4 : 3) * 2.1)) { + if (!$adapter->checkMemoryLimit($file->width, $file->height, $file->fileType)) { return; } - $adapter = ImageHandler::getInstance()->getAdapter(); $adapter->loadFile($file->getLocation()); $updateData = []; diff --git a/wcfsetup/install/files/lib/system/upload/UserCoverPhotoUploadFileValidationStrategy.class.php b/wcfsetup/install/files/lib/system/upload/UserCoverPhotoUploadFileValidationStrategy.class.php index dfcaaf0e33..efc03f5387 100644 --- a/wcfsetup/install/files/lib/system/upload/UserCoverPhotoUploadFileValidationStrategy.class.php +++ b/wcfsetup/install/files/lib/system/upload/UserCoverPhotoUploadFileValidationStrategy.class.php @@ -1,9 +1,9 @@ getFileExtension() == 'png' ? 4 : 3) * 2.1); + $sufficientMemory = ImageHandler::getInstance()->getAdapter()->checkMemoryLimit($width, $height, $imageData['mimeType']); // check width if ($width < UserCoverPhoto::MIN_WIDTH) { -- 2.20.1