Repository navigation
fix: throw RuntimeException when the GD extension is missing in GDHandler - #10824
sgr1806-20 wants to merge 13 commits into
Conversation
ResolvedHi there, @sgr1806-20! 👋 It looks like this pull request does not follow our template:
Please update the description to follow the template. The Hi there, @sgr1806-20! 👋 Thank you for sending this PR! We expect the following in all Pull Requests (PRs).
Important We expect all code changes or bug-fixes to be accompanied by one or more tests added to our test suite to prove the code works. If pull requests do not comply with the above, they will likely be closed. Since we are a team of volunteers, we don't have any more time to work See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md |
michalsn
left a comment
There was a problem hiding this comment.
Thanks, but I would rather follow the path we have in the ImageMagickHandler: https://github.com/codeigniter4/CodeIgniter4/blob/4.8/system/Images/Handlers/ImageMagickHandler.php#L45
Thanks! Switched GDHandler to the same RuntimeException idiom as |
|
CI is green on this revision apart from the Psalm (8.3) job, which is PHP Static Analysis passes now that the stale baseline entry |
|
Please rebase. |
Add method for handling missing PHP extensions in ImageException.
Removed the forMissingExtension method from ImageException.
Removed the missing extension error message from language settings.
Removed test for missing GD extension.
PHPStan fails when an ignored error no longer occurs ("unmatched ignore")
e5303ee to
0aeec13
Compare
Rebased onto the latest 4.8 (d4da78c). Diff unchanged. |
There was a problem hiding this comment.
please don't hand-edit this file. run composer phpstan:baseline instead.
There was a problem hiding this comment.
regenerated with composer phpstan:baseline - header is now 37 and the staticMethod.notFound.neon file is no longer produced.
| use Config\Images; | ||
| use GdImage; | ||
| use Override; | ||
| use RuntimeException; |
There was a problem hiding this comment.
I think this is the framework's RuntimeException, not the native one.
There was a problem hiding this comment.
switched to CodeIgniter\Exceptions\RuntimeException. note that ImageMagickHandler still imports the native RuntimeException — left that alone as it's outside this PR's scope, but happy to change it if you want.
…seline - GDHandler now throws CodeIgniter\Exceptions\RuntimeException - utils/phpstan-baseline regenerated with composer phpstan:baseline
Description
GDHandler called a factory that no longer exists:
On 4.8 that method is undefined (ImageException doesn't define it, and
FrameworkException::forMissingExtension() was removed), so on a host
without the GD extension this fatalised with "Call to undefined method"
instead of throwing a catchable exception.
Rather than re-adding an exception factory, this follows the approach used
by ImageMagickHandler and throws a RuntimeException naming the handler and
the missing extension.
Verified by instantiating GDHandler on a PHP build without GD: before,
Error: Call to undefined method; after, RuntimeException: The
"...\GDHandler" handler requires the "gd" PHP extension.
Checklist: