- πΊπΈUnited States smustgrave
Could we add a simple test case for this issue?
- π¦πΊAustralia dpi Perth, Australia
@smustgrave
We'd need to change either Media class or bundle-class it. Is that going too far for tests?
When passing real integers (not string-ints) to \Drupal\media_library\Ajax\UpdateSelectionCommand
, Media Library will duplicate each ID leading to Media Library exceeding its cardinality (overflow).
UpdateSelectionCommand
is documented as receiving @param int[] $media_ids
, however in practice string[]
is passed. If int[]
is strictly passed, then Media Library will break.
id()
function, such as via Bundle Classes, or coercing the core Media entity class.\Drupal\media_library\Ajax\UpdateSelectionCommand
, coerce each value to an integer, in the constructor: $this->mediaIds = array_map('intval', $media_ids);
.After completing the form and saving for the first time, you'll see +2 added to your selection counter. Which may exceed field cardinality and prevent you from closing the media library window:
When debugging, you'll find a mix of strings/ints in your JS state:
Coerce to ints in Command, and coerce to ints in media library JS.
Note: Fix in π It is possible to overflow the number of items allowed in Media Library Fixed has no effect.
Implement.
Fixes UI bug when PHP code is customised.
Fix data types to follow documented types.
Drupal.MediaLibrary.currentSelection contains ints not strings
Needs work
11.0 π₯
Last updated
Used to track the progress of issues reviewed by the Drupal Needs Review Queue Initiative.
The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Could we add a simple test case for this issue?
@smustgrave
We'd need to change either Media class or bundle-class it. Is that going too far for tests?