-
Notifications
You must be signed in to change notification settings - Fork 32
Fix handle validation on PHP 8 #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PHP 8 switched GD handles from resource to \GdImage object: https://php.watch/versions/8.0/gdimage We need to update the checks appropriately.
Thanks! I'll merge this, run some tests and make a new version soon. |
Thanks, this looks good now. I tried fixing the tests too but got stuck on the BMP code throwing WideImage/lib/vendor/de77/BMP.php Line 49 in e27afc4
Perhaps it should just be https://en.wikipedia.org/wiki/BMP_file_format#Pixel_storage Not sure how it could have ever worked. |
I don't quite have time to dive deep into BMP spec, but I made the following quick fix yesterday and it makes sense to me:
So:
From the wiki you shared:
Unless you see something wrong with this, I'll push this fix up. There are other issues with PHP 8 support, however. I'm thinking I'll release a last minor version for v1 that does not guarantee that it works on anything but 5.3-5.6 really, but should work for most cases up to 8.0. I'll add a v2.0 which fixes some things for 7.0+, but not everything for 8.0. For tests to be fixed on 8.0 I need to bump the minimum PHP version requirement, so that will probably go to v3.0 with a 7.3 or 7.4 minimum requirement and completely fixed tests as right now phpunit is too old to properly run the tests on 8.0. |
@jtojnar I've released the v1.1.4 which includes your PR. |
Your formula is the same as mine and should be right according to my understanding, if we also correct the |
I may be missing something very obvious here, please correct me if I'm wrong. :) My formula: https://3v4l.org/ePRl4 Mine calculates the padding for |
Sorry for the confusion. For some reason, my brain kept returning a negative congruent number ( But your formula does indeed work for 24-bit images since for |
PHP 8 switched GD handles from resource to
\GdImage
object:https://php.watch/versions/8.0/gdimage
We need to update the checks appropriately.
Tested on loading PNG files in selfoss.