What to do with bundled GD's version info?

php.internals

Christoph Becker

8 years ago
Hi everybody! Please consider the following script: <?php echo gd_info()['GD Version'], PHP_EOL, GD_MAJOR_VERSION, '.', GD_MINOR_VERSION, '.', GD_RELEASE_VERSION, PHP_EOL; If PHP is compiled with the *bundled* libgd, it outputs since at least PHP 5.3.25/5.4.1: bundled (2.1.0 compatible) 2.0.35 Obviously, that would mean there have been no relevant changes to the bundled libgd for years, which is not true. Even worse, there has never been a bundled libgd version which was fully compatible to system libgd 2.1.0, ever. Presently, we're somewhat close to libgd 2.2.5, but still we couldn't claim full compatibility. Of course, in the long run the goal is to finally bundle an unmodified copy of the upstream library, but for now that appears out of reach. So the question is how to handle the version information of the bundled libgd for the time being. With regard to gd_info()['GD Version'] just saying "bundled" (without any compatibility statement) might be a good solution. However, I'm at a loss how to handle GD_*_VERSION. Any ideas?
-- Christoph M. Becker

Andrew Faulds

8 years ago
Hi Christoph, Christoph M. Becker wrote:
> So the question is how to handle the version information of the bundled > libgd for the time being. With regard to gd_info()['GD Version'] just > saying "bundled" (without any compatibility statement) might be a good > solution. However, I'm at a loss how to handle GD_*_VERSION. Any ideas?
This might be a bit… maverick, but I wonder if we could get away with a semi-numeric string constant. The string "2-phpbundled" would compare greater than or equal to 2: $ php -r 'var_dump("2-phpbundled" == 2);' bool(true) $ php -r 'var_dump("2-phpbundled" >= 2);' bool(true) The problem is that, well, some code out there might want an actual integer. It's also a bit ugly… Thanks.
-- Andrea Faulds https://ajf.me/

Christoph Becker

8 years ago
Hi Andrea! On 05.02.2018 at 03:35, Andrea Faulds wrote:
> Christoph M. Becker wrote: > >> So the question is how to handle the version information of the bundled >> libgd for the time being.   With regard to gd_info()['GD Version'] just >> saying "bundled" (without any compatibility statement) might be a good >> solution.  However, I'm at a loss how to handle GD_*_VERSION.  Any ideas? > > This might be a bit… maverick, but I wonder if we could get away with a > semi-numeric string constant. The string "2-phpbundled" would compare > greater than or equal to 2: > > $ php -r 'var_dump("2-phpbundled" == 2);' > bool(true) > $ php -r 'var_dump("2-phpbundled" >= 2);' > bool(true) > > The problem is that, well, some code out there might want an actual > integer. It's also a bit ugly…
Thanks! I don't think this would be helpful, though, since GD 2.0 has been released around the millenium, and GD 2.0.1 has already been bundled with PHP since at least PHP 4.3.0. Therefore we can safely assume that nobody uses GD 1 anymore. After reconsideration, it seems to me that we simply can drop the GD_*_VERSION constants for the bundled libgd. Anybody who would using them in combination with the bundled GD is likely to have buggy code, anyway. The only sensible thing to do currently would be to check for `GD_BUNDLED` and to check the PHP version. I've submitted a respective PR: <https://github.com/php/php-src/pull/3080>.
-- Christoph M. Becker