[regression] Add a fallback in DraggableListBuilder::getWeight() to support entities with a NULL weight

Created on 1 March 2024, 9 months ago
Updated 16 March 2024, 8 months ago

Problem/Motivation

πŸ“Œ Extract DraggableListBuilderTrait from DraggableListBuilder for use with content entities Needs work caused a regression for entities with a NULL weight, as DraggableListBuilder::getWeight() is type-hinted to return an int|float value, but it returns NULL in that case.

Steps to reproduce

  1. Create a new taxonomy vocabulary (so that the drag-and-drop interface gets enabled), let's say you called it foo
  2. Run drush cset taxonomy.vocabulary.foo weight --input-format=yaml '~'
  3. Visit the vocabulary overview

See the following exception:

TypeError: Drupal\Core\Config\Entity\DraggableListBuilder::getWeight(): Return value must be of type int|float, null returned in Drupal\Core\Config\Entity\DraggableListBuilder->getWeight() (line 39 of core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php).

Proposed resolution

Add a fallback to 0 in DraggableListBuilder::getWeight().

Remaining tasks

Review MR.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

-

πŸ› Bug report
Status

Fixed

Version

10.3 ✨

Component
EntityΒ  β†’

Last updated about 11 hours ago

Created by

πŸ‡©πŸ‡ͺGermany tstoeckler Essen, Germany

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