`IMAGETYPE_WEBP` is available since PHP 7.1 only
authorAlexander Ebert <ebert@woltlab.com>
Tue, 14 Jan 2020 16:12:07 +0000 (17:12 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 14 Jan 2020 16:12:07 +0000 (17:12 +0100)
wcfsetup/install/files/lib/system/upload/AvatarUploadFileValidationStrategy.class.php

index a5b52ec19d4d83b2600f7e23435199177beec2ae..7125d3f088b36ad8d55711a0c1d68ae1a2428b6d 100644 (file)
@@ -25,7 +25,9 @@ class AvatarUploadFileValidationStrategy extends DefaultUploadFileValidationStra
                                $uploadFile->setValidationErrorType('tooSmall');
                                return false;
                        }
-                       else if ($imageData[2] === IMAGETYPE_WEBP) {
+                       // `IMAGETYPE_WEBP` is available since PHP 7.1, remove the first check as soon as we
+                       // drop the support for ancient PHP versions.
+                       else if (!defined('IMAGETYPE_WEBP') || $imageData[2] === IMAGETYPE_WEBP) {
                                // Reject WebP images regardless of any file extension restriction, they are
                                // neither supported in Safari nor in Internet Explorer 11. We can safely lift
                                // this restriction once Apple implements the support or if any sort of fall-