Refactor GD2 availability check to use GD_MAJOR_VERSION#19820
Merged
MauricioFauth merged 3 commits intophpmyadmin:masterfrom Aug 25, 2025
Merged
Refactor GD2 availability check to use GD_MAJOR_VERSION#19820MauricioFauth merged 3 commits intophpmyadmin:masterfrom
MauricioFauth merged 3 commits intophpmyadmin:masterfrom
Conversation
Replaced fragile checks (`imagecreatetruecolor`, `gd_info`, phpinfo parsing) with the GD_MAJOR_VERSION constant (available since PHP 5.2.4). This avoids false positives (e.g. matching "2." in "3.2.0") and false negatives (e.g. missing "3.0.0"), making detection precise. Updated PHPUnit tests accordingly. Signed-off-by: Hendrik Becker <[email protected]>
williamdes
approved these changes
Aug 23, 2025
Member
williamdes
left a comment
There was a problem hiding this comment.
It's probably worth sending this to QA_5_2 too
Contributor
Author
|
The code in master has been refactored, so this can’t be cherry-picked. I can prepare a backport for QA_5_2 if that’s desired. |
Member
Sure, if there is no particular risks please do a backport |
- Replace constant('GD_MAJOR_VERSION') >= 2 with runtime lookup to prevent PHPStan’s “2 >= 2 always true”.
- Remove redundant defined('GD_MAJOR_VERSION') branch; behavior unchanged (?? 0 covers missing constant).
Signed-off-by: Hendrik Becker <[email protected]>
MauricioFauth
approved these changes
Aug 23, 2025
LuckyFellow
added a commit
to LuckyFellow/phpmyadmin
that referenced
this pull request
Aug 23, 2025
Adapted from phpmyadmin#19820; replaces legacy checks, updates test, no functional change beyond precise version detection. Signed-off-by: Hendrik Becker <[email protected]>
Contributor
Author
|
CI failures look unrelated to these changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This refactors the GD2 availability detection to use the GD_MAJOR_VERSION constant
(available since PHP 5.2.4) instead of fragile checks with
imagecreatetruecolor,gd_info, or parsing phpinfo output.The previous implementation could lead to:
With this change, both implementation and PHPUnit tests now rely on
GD_MAJOR_VERSION as the single source of truth, ensuring precise detection
and simplifying the code.
Before submitting pull request, please review the following checklist:
Signed-off-byline as described in our DCO. This ensures that the work you're submitting is your own creation.