Config overrides cause PHP warning and missing link text

Created on 12 May 2025, 26 days ago

Problem/Motivation

Since version 2.2.0, storing a config override results in a PHP warning and missing link text when viewing the CSP settings form.

Steps to reproduce

  • Install the latest D10 core (currently 10.4.7).
  • Install any version of the CSP module after 2.2.0 (currently 2.2.2).
  • In settings.php, add the following config overrides:
$config['csp.settings']['report-only']['directives']['frame-src']['base'] = 'self';
$config['csp.settings']['report-only']['directives']['frame-src']['sources'][] = 'https://www.example.com';
  • Clear site caches.
  • Visit the CSP settings form at /admin/config/system/csp.
  • Note the PHP warnings and the missing link text for one of the listed overrides:
Warning: Undefined array key "#title" in Drupal\Core\Form\ConfigFormBase->checkConfigOverrides() (line 361 of core/lib/Drupal/Core/Form/ConfigFormBase.php).
Warning: Undefined array key "#title" in Drupal\Core\Form\ConfigFormBase->checkConfigOverrides() (line 363 of core/lib/Drupal/Core/Form/ConfigFormBase.php).

Source code of the config override warning links displayed in the status message:

<ul class="links">
  <li><a href="#edit-report-only-directives-frame-src" title="&#039;&#039; form element"></a></li>
  <li><a href="#edit-report-only-directives-frame-src-sources" title="&#039;Additional Sources&#039; form element">Additional Sources</a></li>
</ul>

Proposed resolution

Add the '#title' attribute to all generated settings form fields.

In addition to the missing link text, there are going to be some usability/accessibility issues if more than one similarly-named setting is overridden. All of the "additional sources" overrides in the status message will have the same link text, for example. It will be hard for site admins to know which values are actually overridden. So it would be nice to have some text to disambiguate the fields.

In the 2.0.x version of the CSP module, overrides were output as a dump of YAML-like text, which was hard to read but if you looked carefully you could see the hierarchy of config key names.

Remaining tasks

Update and test.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States cboyden

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024