Summary
Drupal core 11.4 introduced a fonts: key in libraries.yml for native font preloading (core issue #3366561, change record https://www.drupal.org/node/3585574). A user reported PHP warnings when running Drupal 11.4.1 with the DXPR suite, including a grep result showing fonts: entries in dxpr_theme.libraries.yml at lines 211 and 219.
The current 8.x branch does not contain any fonts: entries in dxpr_theme.libraries.yml, so the user's installation appears to have been modified (possibly to mirror the font preloading entries added to dxpr_builder in PR dxpr/dxpr_builder#4745).
This issue tracks two concerns:
-
If fonts: entries are added to dxpr_theme in the future, they must use YAML mapping syntax (path: {preload: true}) rather than list syntax (- path). List syntax produces integer keys that cause "Undefined array key preload" errors in HtmlResponseAttachmentsProcessor. See dxpr/dxpr_builder#4775 for the equivalent fix in dxpr_builder.
-
The existing custom font preloading code in features/sooper-fonts/fonts-theme-settings-controller.inc uses #attached['html_head'] to add preload link tags. This approach is independent of the fonts: API and should continue to work, but should be evaluated for potential migration to the core fonts API in a future release.
Steps to reproduce
- Install Drupal 11.4.1 with dxpr_theme
- Add
fonts: entries using YAML list syntax to dxpr_theme.libraries.yml (e.g., fonts:\n - path/to/font.woff2)
- Clear caches and load any page
What is the current bug behavior?
PHP warning: Undefined array key "preload" in Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments() (line 132).
What is the expected correct behavior?
No PHP warnings. Font entries should use the mapping syntax expected by Drupal 11.4:
fonts:
path/to/font.woff2:
preload: true
Relevant logs and/or screenshots
Error from user report:
Warning: Undefined array key "preload" in Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments() (line 132 of core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php).
Possible fixes
If fonts: entries are needed, use mapping syntax with explicit preload flag. See dxpr/dxpr_builder#4776 for the equivalent fix pattern.
Summary
Drupal core 11.4 introduced a
fonts:key inlibraries.ymlfor native font preloading (core issue #3366561, change record https://www.drupal.org/node/3585574). A user reported PHP warnings when running Drupal 11.4.1 with the DXPR suite, including a grep result showingfonts:entries indxpr_theme.libraries.ymlat lines 211 and 219.The current
8.xbranch does not contain anyfonts:entries indxpr_theme.libraries.yml, so the user's installation appears to have been modified (possibly to mirror the font preloading entries added to dxpr_builder in PR dxpr/dxpr_builder#4745).This issue tracks two concerns:
If
fonts:entries are added to dxpr_theme in the future, they must use YAML mapping syntax (path: {preload: true}) rather than list syntax (- path). List syntax produces integer keys that cause "Undefined array key preload" errors inHtmlResponseAttachmentsProcessor. See dxpr/dxpr_builder#4775 for the equivalent fix in dxpr_builder.The existing custom font preloading code in
features/sooper-fonts/fonts-theme-settings-controller.incuses#attached['html_head']to add preload link tags. This approach is independent of thefonts:API and should continue to work, but should be evaluated for potential migration to the core fonts API in a future release.Steps to reproduce
fonts:entries using YAML list syntax todxpr_theme.libraries.yml(e.g.,fonts:\n - path/to/font.woff2)What is the current bug behavior?
PHP warning:
Undefined array key "preload"inDrupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments()(line 132).What is the expected correct behavior?
No PHP warnings. Font entries should use the mapping syntax expected by Drupal 11.4:
Relevant logs and/or screenshots
Error from user report:
Possible fixes
If
fonts:entries are needed, use mapping syntax with explicitpreloadflag. See dxpr/dxpr_builder#4776 for the equivalent fix pattern.