07 · Theme crashes with a ValueError when the site language is not a valid ICU locale¶
| Project | Event Horizon (theme of the Summit site template) |
| Component | Code |
| Category | Bug report |
| Priority | Normal |
| Status | Reported upstream as #3613748 |
Problem/Motivation¶
event_horizon.theme (around line 88) creates a NumberFormatter with the current language code. If the site language is und (which happens when Drupal CMS detects the template's language wrongly, see the related Drupal CMS issue) every page fails:
ValueError: NumberFormatter::__construct(): Argument #1 ($locale) "und" is invalid
Steps to reproduce¶
- Set
system.site:default_langcodetoundon a Summit site (or reproduce via the Drupal CMS installer bug). - Visit any page → 500.
Proposed resolution¶
Catch the ValueError (or validate the locale) and fall back to en.
Remaining tasks¶
Patch.
Additional information¶
Side finding while testing Summit: the log shows "Non-existent permission(s) assigned to role "Authenticated user": flag my_schedule, unflag my_schedule."
Copy to drupal.org
Issue title:
Theme crashes with a ValueError when the site language is not a valid ICU locale
Issue summary (paste it into the "Issue summary" field; project, component, category and priority are in the table above):
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p><code>event_horizon.theme</code> (around line 88) creates a <code>NumberFormatter</code> with the current language code. If the site language is <code>und</code> (which happens when Drupal CMS detects the template's language wrongly, see the related Drupal CMS issue) every page fails:</p>
<code>ValueError: NumberFormatter::__construct(): Argument #1 ($locale) "und" is invalid</code>
<h3 id="summary-steps-reproduce">Steps to reproduce</h3>
<ol>
<li>Set <code>system.site:default_langcode</code> to <code>und</code> on a Summit site (or reproduce via the Drupal CMS installer bug).</li>
<li>Visit any page → 500.</li>
</ol>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Catch the <code>ValueError</code> (or validate the locale) and fall back to <code>en</code>.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>Patch.</p>
<h3>Additional information</h3>
<p>Side finding while testing Summit: the log shows "Non-existent permission(s) assigned to role "Authenticated user": flag my_schedule, unflag my_schedule."</p>