Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Recently an improvement was made to the media library so extra parameters are ignored.
However the order for the $allowed_media_type_ids and $opener_parameters are not sorted by key.
This can lead to different hashes when clicking the button and uploading the media.
This is hard to reproduce as it only happened on a single environment.
The order is important as a hash will be different when the order changes.
I have added a patch which fixes this behaviour.
Comment | File | Size | Author |
---|---|---|---|
#10 | 3076259-10.patch | 2.58 KB | oknate |
#10 | 3076259-10--FAIL.patch | 1.29 KB | oknate |
#10 | 3076259--interdiff-5-10.txt | 2.47 KB | oknate |
#5 | 3076259-5.patch | 2.45 KB | oknate |
#5 | 3076259--interdiff-4-5.txt | 739 bytes | oknate |
Comments
Comment #2
cilefen CreditAttribution: cilefen commentedComment #3
phenaproximaI think we can easily test this with a kernel test:
Tagging for tests and marking as "needs work". Once we have that, we can easily land this. Very nice find!
Comment #4
oknateHere's test coverage. I also moved the sorting into getHash(), as I think that's more appropriate.
We don't really need to be massaging the values in ::create() and and it was redundant in the following code, since it was being passed to create() just after.
3)
ksort($allowed_media_type_ids)
fails when they are passed without keys, such as ['image', 'file'], so changed that up a bit:Comment #5
oknateOops, I left some test code in there while trying to figure out #4.3. Removing it.
Comment #8
oknateRetriggering test of #5, It looks like a random failure.
Comment #9
phenaproximaLooking excellent! Can't wait to RTBC this bugfix. I'm nominating it for backport to 8.7.x because it is a non-disruptive bug fix, in an experimental module, no less.
Nit: There is an extra space before "Sort".
Good call on using
array_values()
! 👍This is a little more verbose than it needs to be. We can combine $state and $state3, and $state2 and $state4, and still get the same amount of test coverage.
Comment #10
oknate1. Removed extra space.
3. After discussing this with @phenaproxima on Slack, I broke it up into two methods, one to test allowed media types and one to test open parameters. He agreed with me that keeping the two separate sets of tests is OK, as it tests the allowed view modes and the opener params in isolation.
Comment #12
phenaproximaLooks good to me. RTBC when Christmas-ey.
Comment #13
alexpottCommitted 5a2c58c and pushed to 8.8.x. Thanks!
Comment #17
phenaproximaThanks!
Comment #18
josephdpurcell CreditAttribution: josephdpurcell at Bounteous commentedLinking to other tickets to increase the likelihood someone finds this issue.