From 79235b6db1c9badd6c9602d54ad0d550e4bec2fd Mon Sep 17 00:00:00 2001 From: Marek Bachmann Date: Wed, 30 Nov 2022 05:17:48 +0100 Subject: [PATCH] Removed redundant maximagesize = INF statements --- mod/photos.php | 4 ---- src/Model/Photo.php | 12 ++---------- src/Module/Media/Photo/Upload.php | 6 +----- src/Module/Settings/Profile/Photo/Index.php | 4 ---- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index 4436da5d6..14eb88ac9 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -656,10 +656,6 @@ function photos_post(App $a) $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - if ($maximagesize == 0) { - $maximagesize = INF; - } - if ($maximagesize && ($filesize > $maximagesize)) { DI::sysmsg()->addNotice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize))); @unlink($src); diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 1250ad570..126bc152b 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -577,11 +577,7 @@ class Photo $filesize = strlen($image->asString()); $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - if ($maximagesize == 0) { - $maximagesize = INF; - } - - if (!empty($maximagesize) && ($filesize > $maximagesize)) { + if ($maximagesize && ($filesize > $maximagesize)) { Logger::info('Avatar exceeds image limit', ['uid' => $uid, 'cid' => $cid, 'maximagesize' => $maximagesize, 'size' => $filesize, 'type' => $image->getType()]); if ($image->getType() == 'image/gif') { $image->toStatic(); @@ -973,11 +969,7 @@ class Photo $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - if ($maximagesize == 0) { - $maximagesize = INF; - } - - if (!empty($maximagesize) && ($filesize > $maximagesize)) { + if ($maximagesize && ($filesize > $maximagesize)) { // Scale down to multiples of 640 until the maximum size isn't exceeded anymore foreach ([5120, 2560, 1280, 640] as $pixels) { if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) { diff --git a/src/Module/Media/Photo/Upload.php b/src/Module/Media/Photo/Upload.php index ec8dbcf70..885aa8614 100644 --- a/src/Module/Media/Photo/Upload.php +++ b/src/Module/Media/Photo/Upload.php @@ -171,11 +171,7 @@ class Upload extends \Friendica\BaseModule $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - if ($maximagesize == 0) { - $maximagesize = INF; - } - - if (!empty($maximagesize) && $filesize > $maximagesize) { + if ($maximagesize && $filesize > $maximagesize) { // Scale down to multiples of 640 until the maximum size isn't exceeded anymore foreach ([5120, 2560, 1280, 640] as $pixels) { if ($filesize > $maximagesize && max($width, $height) > $pixels) { diff --git a/src/Module/Settings/Profile/Photo/Index.php b/src/Module/Settings/Profile/Photo/Index.php index ee551f88b..26caae965 100644 --- a/src/Module/Settings/Profile/Photo/Index.php +++ b/src/Module/Settings/Profile/Photo/Index.php @@ -55,10 +55,6 @@ class Index extends BaseSettings $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize', 0)); - if ($maximagesize == 0) { - $maximagesize = INF; - } - if ($maximagesize && $filesize > $maximagesize) { DI::sysmsg()->addNotice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize))); @unlink($src);