Problem/Motivation
After upgrading PHP 7.4 to 8.0, we get the following error:
TypeError: Unsupported operand types: int / string in Drupal\image_widget_crop\Element\ImageCrop::processCrop() (line 237 of /var/www/html/web/modules/contrib/image_widget_crop/src/Element/ImageCrop.php)
This is a result of division by empty String ($height or $height_ration)
Steps to reproduce
Go to Content -> Media -> Add Image, when you upload a new image, nothing would happen
In the logs, we find the following:
TypeError: Unsupported operand types: int / string in Drupal\image_widget_crop\Element\ImageCrop::processCrop() (line 237 of /var/www/html/web/modules/contrib/image_widget_crop/src/Element/ImageCrop.php)
#0 [internal function]: Drupal\image_widget_crop\Element\ImageCrop::processCrop(Array, Object(Drupal\Core\Form\FormState), Array)
#1 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1007): call_user_func_array(Array, Array)
#2 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1070): Drupal\Core\Form\FormBuilder->doBuildForm('media_image_add...', Array, Object(Drupal\Core\Form\FormState))
Comments
Comment #2
baskaran CreditAttribution: baskaran commented@mustafa.hajmohammed I am not able to reproduce this issue in 8.x-2.3 version. Either you upgrade the module to the 8.x-2.4 version or check if any patches applied.
Comment #3
ramu_bharu CreditAttribution: ramu_bharu as a volunteer and commentedThanks @baskaran for your reply.
Yes, we used this patch for default crop functionality and it seems to be breaking.
Issue: https://www.drupal.org/project/image_widget_crop/issues/2865396
Mustafa, I tried the latest patch and it seems to be working fine. Thanks
Comment #4
mustafa.hajmohammed CreditAttribution: mustafa.hajmohammed as a volunteer commentedThank you @ramu_bharu, it worked!
Comment #5
mustafa.hajmohammed CreditAttribution: mustafa.hajmohammed at Merkle commented