- Issue created by @calebtr
- Status changed to Closed: duplicate
3 months ago 4:35pm 30 May 2024 - πΊπΈUnited States calebtr
Fixed in π core.libraries.yml mis-implements moved_files syntax Fixed
In Drupal 10.3, there is a new yaml key in *.libraries.yml, moved_files to indicate a file has moved. Also in Drupal 10.3, a bunch of core files have moved and this key is set in core.libraries.yml
.
LibraryDiscoveryParser.php::applyLibrariesMovedOverrides()
and supporting test cases are expecting the key values to be arrays, but the values set in the updated core.libraries.yml file are coded as yaml strings. This generates an error:
Fatal error: Uncaught TypeError: array_key_first(): Argument #1 ($array) must be of type array, string given in /var/www/html/docroot/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php on line 455
e.g. for drupal.ajax, the key under 'drupal.ajax/moved_files/system/base/css/component' has a value that is a string:
drupal.ajax:
version: VERSION
js:
misc/ajax.js: {}
css:
component:
misc/components/ajax-progress.module.css: { weight: -10 }
moved_files:
system/base:
deprecation_version: 10.3.0
removed_version: 11.0.0
deprecation_link: https://www.drupal.org/node/3432346
css:
component:
css/components/ajax-progress.module.css: misc/components/ajax-progress.module.css
LibraryDiscoveryParser
is assuming that a yml mapping has been converted to a PHP array.
1. Install latest Drupal 10.3.0-beta1 or greater.
2. Install a project that overrides libraries that were moved in
π
Move system/base component CSS to respective libraries where they exist
Fixed
, e.g. drupal/stable
3. Load a page that uses the overridden library. e.g. enable and set the contributed Stable theme as the default theme.
drush cr
can trigger the error also.
Allow keys for overridden libraries to be strings OR arrays.
1. Check to see if the value is an array before passing it to array_key_exists()
.
2. Add a test case in which the key value of the overridden library is a string
It looks like it would be possible to code the yml as a sequence/array instead of a mapping, but I don't know enough about the asset system to say if that would ever come up. Should we check for that case also?
Alternatively, update the yaml structures in core.libraries.yml to make these keys into yaml mappings instead of strings.
Closed: duplicate
11.0 π₯
Fixed in π core.libraries.yml mis-implements moved_files syntax Fixed