TypeError: Unsupported operand types: int / string

Created on 1 February 2023, almost 2 years ago
Updated 19 February 2023, over 1 year ago

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))

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.3

Component

Code

Created by

🇨🇭Switzerland mustafa.hajmohammed

Live updates comments and jobs are added and updated live.
  • PHP 8.0

    The issue particularly affects sites running on PHP version 8.0.0 or later.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024