$cardinality variable being set as string and failing strict type check

Created on 6 March 2024, 4 months ago

Problem/Motivation

The $cardinality variable being set on line 17 of /field_config_cardinality/src/Plugin/Field/FieldWidget/CardinalityMediaLibraryWidget.php needs to be stored as an integer. Currently it is stored as a string, which then fails the strict type check in line 473 of /core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php

$cardinality_unlimited = ($element['#cardinality'] === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);

Steps to reproduce

  1. Add a media library field with unlimited cardinality
  2. Add a media item to the widget
  3. See that the message that shows is "-1 media items remaining"

Proposed resolution

Cast the $cardinality variable as an integer.

Remaining tasks

Make the changes

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Closed: cannot reproduce

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Hebl

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

Comments & Activities

Production build 0.69.0 2024