TypeError: uasort(): Argument #1 ($array) must be of type array, null given in uasort()

Created on 24 January 2025, 4 months ago

Problem/Motivation

Selecting entity types twice in the same operation results in the following error:

TypeError: uasort(): Argument #1 ($array) must be of type array, null given in uasort() (line 65 of core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php

What's weird is that it works the first time the form loads, but the second click causes the error. This is repeatable - odd clicks work, even clicks fail, regardless of how many are selected or which ones are clicked.

Steps to reproduce

Add a new DER field to a content type.
In the entity type selection, uncheck "Exclude", then select an entity type - the first time something is selected it will work, the second time it will throw the error above.

Proposed resolution

Fix the bug =)

Remaining tasks

Fix the bug.
Add test coverage.

User interface changes

Clicking the "Select items" doesn't trigger the error above.

API changes

TBD

Data model changes

n/a

πŸ› Bug report
Status

Active

Version

3.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

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

Comments & Activities

Production build 0.71.5 2024