Wrong precedence of the && operator

Created on 22 June 2023, over 1 year ago
Updated 26 October 2023, about 1 year ago

Problem/Motivation

TypeError: _field_zip_file(): Argument #1 ($file) must be of type Drupal\file\Entity\File, null given.

This is caused by ZipFileBase::getUrl()
if ($file = $zip_file->get('entity')->getValue() && $file_info = _field_zip_file($file)) {
This if condition is wrong, the $file parameter is always NULL.
explanation with example: stackoverflow.com

Steps to reproduce

Proposed resolution

Additional parenthesis solves the problem.
Restructuring the code to not use any assignments inside if conditions would be nice.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.1

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary pasqualle πŸ‡­πŸ‡Ί Budapest

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

Comments & Activities

Production build 0.71.5 2024