Cache rebuild can trigger an infinite loop

Created on 11 June 2024, 10 months ago
Updated 13 September 2024, 7 months ago

Problem/Motivation

At some point a cache rebuild started triggering an infinite loop in code, taking down our staging server. The reason is that Drupal\domain_language\LanguageDefault::get() tries to load \Drupal::config('system.site'), causing Drupal\domain_language\DomainLanguageOverrider::loadOverrides() to kick in. That one calls $this->currentUser->hasPermission('bypass language restrictions') if the loaded config is system.site, triggering Drupal\domain_language\LanguageDefault::get() again.

Steps to reproduce

For me a cache rebuild through the admin toolbar is enough to trigger it.

Proposed resolution

No idea yet.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇧🇪Belgium dieterholvoet Brussels

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

Merge Requests

Comments & Activities

  • Issue created by @dieterholvoet
  • 🇧🇪Belgium dieterholvoet Brussels

    The original Drupal\Core\Language\LanguageDefault has the following class comment:

    Provides a simple get and set wrapper to the default language object.
    The default language must be provided without dependencies since it is both
    configured and a dependency of the configuration system. The LanguageDefault
    object is a container service. The default values are stored on the container
    by \Drupal\Core\DrupalKernel::buildContainer(). This allows services to
    override this parameter in a ServiceProvider, for example,
    \Drupal\language\LanguageServiceProvider::alter().

    I think this means that we can't read config in Drupal\domain_language\LanguageDefault.

  • 🇧🇪Belgium dieterholvoet Brussels

    I do get that we can't store the default language in the container as that class suggests, since it can vary per request. At the very least we should make sure to not read system.site config in Drupal\domain_language\LanguageDefault.

  • Merge request !13Fix infinite loop → (Merged) created by dieterholvoet
  • Status changed to Needs review 10 months ago
  • Pipeline finished with Failed
    10 months ago
    Total: 500s
    #196234
  • Status changed to RTBC 8 months ago
  • 🇭🇺Hungary denes.szabo Hungary

    I can confirm, this fix solved my problem on my site.

  • Status changed to Fixed 7 months ago
  • 🇧🇪Belgium JeroenT 🇧🇪

    Merged to 8.x-1.x. Thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024