- π·π΄Romania bbu23
Actually this bug is quite interesting. I have the following scenario on CLARO theme:
On two environments, let's call them:
- LOCAL
- REMOTEThe environments have the same codebase. One of them has the bug, the other one doesn't if we use the non-zero key:
e.g.
unset($media_type_ids['image']); $media_type_ids = ['image' => 'image'] + $media_type_ids;
What I noticed in REMOTE environment is that the
media_library_allowed_types
array parameter that is sent to MediaLibraryState gets its keys reordered alphabetically. In MediaLibraryState in construct, even though the parameters are set in the correct order just before, they arrive sorted by keys alphabetically. In the LOCAL environment, the order is kept.If
array_unshift($media_type_ids, 'image');
is used in both environments, then the order is not altered anymore because the key 0 will be in the top of the array no matter what.On the remote environment, I changed the image key to be
unset($media_type_ids['image']); $media_type_ids = ['aaimage' => 'image'] + $media_type_ids;
and then
unset($media_type_ids['image']); $media_type_ids = ['bbimage' => 'image'] + $media_type_ids;
which showed that the parameters are sorted by keys and placed the Image tab first for the first case, and second for the second case.
This concludes that it is not related to the Claro theme, but I don't know if it's a server issue, or anything else. But since the LOCAL parameters are not sorted at all when they arrive in the MediaLibraryState construct for the exact same code, it could be something else outside of Drupal.