Deprecated: round() imagetoolkit (D11 / PHP 8.3)

Created on 29 April 2025, 5 months ago

Problem/Motivation

I'm using Drupal 11.1 and PHP 8.3.
While playing adding watermarking on an image style, I got the error

Deprecated function: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in Drupal\system\Plugin\ImageToolkit\Operation\gd\Resize->validateArguments() (line 39 of core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php).

Proposed resolution

In core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php, it looks like

  protected function validateArguments(array $arguments) {
    // Assure integers for all arguments.
    $arguments['width'] = (int) round($arguments['width']);
    $arguments['height'] = (int) round($arguments['height']);

should be relaced with

  protected function validateArguments(array $arguments) {
    // Assure integers for all arguments.
    $arguments['width'] = round((int) $arguments['width']);
    $arguments['height'] = round((int) $arguments['height']);

Remaining tasks

Attached patch is a starting point, MR is coming.

πŸ› Bug report
Status

Needs review

Version

11.1 πŸ”₯

Component

system.module

Created by

πŸ‡«πŸ‡·France PhilY πŸ‡ͺπŸ‡ΊπŸ‡«πŸ‡· Paris, France

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024