Issue with conditional logic leading to incorrect evaluations

Created on 17 April 2024, 7 months ago

Problem/Motivation

The conditional statement in question is:

if ($item->target_id == $file->id() && $item->width != $width || $item->height != $new_height)

in the ImageResize.php from the QueueWorker
This condition mistakenly evaluates to true when $item->target_id is not equal to $file->id(), yet $item->height does not match new_height.
The expected behavior is for all checks to be associated with the condition where $item->target_id == $file->id().

Proposed resolution

To address this issue, the logical grouping in the conditional expression needs adjustment. The corrected version of the code should use parentheses to ensure the right order of evaluation:

if ($item->target_id == $file->id() && ($item->width != $width || $item->height != $new_height))

This adjustment will ensure that the width and height checks are only considered when the target ID actually matches.

Remaining tasks

Provide a MR

User interface changes

none

API changes

none

Data model changes

none

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇪🇸Spain isaacrc

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