fix: #3618848 Read the editor settings of both stored shapes when building the libraries

Fixes #3618848.

getLibraries() was the only method that indexed the nested fieldset key unconditionally. settingsForm() and getJsSettings() already accepted both shapes the module can store, so a text format whose settings are stored flat, as a recipe, a configuration import or an older release leaves them, raised six messages on every render of a text format element:

Warning: Undefined array key "fieldset" ... getLibraries() (line 165)
Warning: Trying to access array offset on null ... getLibraries() (line 165)
Deprecated function: trim(): Passing null to parameter #1 ($string) ... getLibraries() (line 165)

(and the same three for line 166)

Beyond the noise the theme was wrong: $theme and $mode came out empty, the library existence check failed, and the format was rendered with the site-wide default theme instead of its own.

A node edit form attaches the editor of every text format the user may use, so one flat-configured format fills unrelated forms with these messages.

Changes

  • The normalisation getJsSettings() already carried moves into a shared instanceSettings() helper; getLibraries() reads the theme and syntax through it. Both shapes are now handled in one place.
  • Kernel coverage: the libraries of both shapes, the defaults of empty settings, and that no warning is raised for any shape.

Verification

Reproduced and fixed on Drupal 10.6.15 and Drupal 11.4.5 (PHP 8.4). On a site with a flat-configured format, all six messages are gone and the format now resolves its own theme:

ace_html  (nested) -> ace_editor/theme.monokai  ace_editor/mode.html
full_html (flat)   -> ace_editor/theme.chrome   ace_editor/mode.html

Local gate green: PHPUnit 42 tests / 113 assertions, phpcs (Drupal, DrupalPractice), cspell, eslint. PHPStan could only be approximated locally, since the repository ships a baseline and the configuration comes from the drupalci templates, so that job gates on this pipeline.

A NULL fieldset is rejected by the configuration schema and so cannot be stored, but the guard still covers it at runtime; that case is asserted on an unsaved editor.

Checkpoints:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Developer Documentation
  • User Guide Documentation
  • Reviewed by human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release

AI-Generated: Yes

Edited by Rajab Natshah

Merge request reports

Loading
Loading