Skip to content
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

Fix configuration of gd in base images below PHP 7.4 #380

Merged

Conversation

Quetzacoalt91
Copy link
Member

@Quetzacoalt91 Quetzacoalt91 commented Apr 11, 2024

Questions Answers
Description? When running versions of PrestaShop with old base images, imagecreatefromjpeg() is undefined. This is caused by a change we applied on all images about GD, which actually only valid from PHP 7.4. Although it never failed, the gd extension was not loaded on previous versions.
Type? bug fix
BC breaks? Nope
Deprecations? Nope
Fixed ticket? Unblocks PrestaShop/autoupgrade#688
Sponsor company /
How to test? Look below

How to test

  • Reach the folder base/images/7.1-apache
  • Build the image with the command docker build -t prestashop/base:test-7.1-apache .
  • Wait for the build to succeed
  • Run the container with docker run --rm -ti --entrypoint="php" prestashop/base:test-7.1-apache
  • You will be able to write PHP code to check the gd library is properly loaded. Paste this code then quit with ctrl+D or cmd+D
<?php

imagecreatefromjpeg();
  • If you build from the master branch this error will be reported: PHP Fatal error: Uncaught Error: Call to undefined function imagecreatefromjpeg() in -:3
  • From this PR, you get another error because I didn't send any parameters, but at least the function now exists: PHP Warning: imagecreatefromjpeg() expects exactly 1 parameter, 0 given in - on line 3

Reported errors:

prestashop_autoupgrade | [Thu Apr 11 16:50:41.395837 2024] [php7:error] [pid 65] [client 192.168.0.1:42770] PHP Fatal error: Uncaught Error: Call to undefined function imagecreatefromjpeg() in /var/www/html/classes/ImageManager.php:533\nStack trace:\n#0 /var/www/html/classes/ImageManager.php(260): ImageManagerCore::create(2, '/var/www/html/i...')\n#1 /var/www/html/src/Adapter/Image/ImageRetriever.php(151): ImageManagerCore::resize('/var/www/html/i...', '/var/www/html/i...', 800, 800)\n#2 /var/www/html/src/Adapter/Image/ImageRetriever.php(80): PrestaShop\\PrestaShop\\Adapter\\Image\\ImageRetriever->getImage(Object(Product), '1')\n#3 [internal function]: PrestaShop\\PrestaShop\\Adapter\\Image\\ImageRetriever->PrestaShop\\PrestaShop\\Adapter\\Image\\{closure}(Array)\n#4 /var/www/html/src/Adapter/Image/ImageRetriever.php(90): array_map(Object(Closure), Array)\n#5 /var/www/html/src/Core/Product/ProductPresenter.php(95): PrestaShop\\PrestaShop\\Adapter\\Image\\ImageRetriever->getProductImages(Array, Object(Language))\n#6 /var/www/html/src/Core/Product/ProductPresenter.php(563): PrestaShop\\PrestaShop\\Core\\Product\\ProductPresenter->fillImages(Array, Object(Presta in /var/www/html/classes/ImageManager.php on line 533

@Quetzacoalt91 Quetzacoalt91 self-assigned this Apr 11, 2024
Copy link

@AureRita AureRita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @

Thank you for your PR, I tested it and it seems to works as you can see :

image

Because the PR seems to works as expected, It's QA ✔️

Thank you

@Quetzacoalt91 Quetzacoalt91 merged commit e361f0b into PrestaShop:master Apr 15, 2024
2 checks passed
@Quetzacoalt91 Quetzacoalt91 deleted the fix-configuration-of-gd branch April 15, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants