Edge case: $settings->get('enable_darkmode') can cause WSOD

Created on 6 March 2025, about 1 month ago

Problem/Motivation

My edge case is that I have Gin as the frontend theme and Claro as the backend theme. Yes, I know this is crazy, and I've only switched to Claro temporarily to test something, ensuring that a render issue in views is not caused by Gin.

But this crazy scenario exposed a tiny issue that can easily be resolved. In gin_page_attachments_alter we call this:

'#value' => new FormattableMarkup('{ "ginDarkmode": "@value" }', ['@value' => $settings->get('enable_darkmode')]),

In the scenario above, the setting returns NULL which will later be passed on to \Drupal\Component\Utility\Html::escape and that throws an exception because the given text has to be string and can't be NULL.

Proposed resolution

Provide a default value in this case.

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇩🇪Germany jurgenhaas Gottmadingen

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024