Problem/Motivation

#2989889: Extract DraggableListBuilderTrait from DraggableListBuilder for use with content entities 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

-

Issue fork drupal-3425058

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tstoeckler created an issue. See original summary.

tstoeckler’s picture

Status: Active » Needs review
andypost’s picture

Status: Needs review » Reviewed & tested by the community

Thank you!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed a957a4acfc to 11.x and d4565e1788 to 10.3.x. Thanks!

  • alexpott committed d4565e17 on 10.3.x
    Issue #3425058 by tstoeckler: [regression] Add a fallback in...

  • alexpott committed a957a4ac on 11.x
    Issue #3425058 by tstoeckler: [regression] Add a fallback in...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.