Commit c9160852 authored by catch's avatar catch
Browse files

Issue #3441222 by kristiaanvandeneynde, nicxvan, catch, alexpott, smustgrave,...

Issue #3441222 by kristiaanvandeneynde, nicxvan, catch, alexpott, smustgrave, lauriii, quietone: Allow update.php to load when entity type info needs to be updated
parent bb543187
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1574,7 +1574,7 @@ services:
  Drupal\Core\Theme\ThemeInitializationInterface: '@theme.initialization'
  theme.registry:
    class: Drupal\Core\Theme\Registry
    arguments: ['%app.root%', '@cache.default', '@lock', '@module_handler', '@theme_handler', '@theme.initialization', '@cache.bootstrap', '@extension.list.module']
    arguments: ['%app.root%', '@cache.default', '@lock', '@module_handler', '@theme_handler', '@theme.initialization', '@cache.bootstrap', '@extension.list.module', '@kernel']
    tags:
      - { name: needs_destruction }
    calls:
+33 −5
Original line number Diff line number Diff line
@@ -10,7 +10,9 @@
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Lock\LockBackendInterface;
use Drupal\Core\Update\UpdateKernel;
use Drupal\Core\Utility\ThemeRegistry;
use Symfony\Component\HttpKernel\HttpKernelInterface;

/**
 * Defines the theme registry service.
@@ -178,10 +180,12 @@ class Registry implements DestructableInterface {
   *   The cache backend interface to use for the runtime theme registry data.
   * @param \Drupal\Core\Extension\ModuleExtensionList $module_list
   *   The module list.
   * @param \Symfony\Component\HttpKernel\HttpKernelInterface|null $kernel
   *   The kernel.
   * @param string $theme_name
   *   (optional) The name of the theme for which to construct the registry.
   */
  public function __construct($root, CacheBackendInterface $cache, LockBackendInterface $lock, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, ThemeInitializationInterface $theme_initialization, CacheBackendInterface $runtime_cache, ModuleExtensionList $module_list, $theme_name = NULL) {
  public function __construct($root, CacheBackendInterface $cache, LockBackendInterface $lock, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, ThemeInitializationInterface $theme_initialization, CacheBackendInterface $runtime_cache, ModuleExtensionList $module_list, protected ?HttpKernelInterface $kernel = NULL, $theme_name = NULL) {
    $this->root = $root;
    $this->cache = $cache;
    $this->lock = $lock;
@@ -191,6 +195,11 @@ public function __construct($root, CacheBackendInterface $cache, LockBackendInte
    $this->runtimeCache = $runtime_cache;
    $this->moduleList = $module_list;
    $this->themeName = $theme_name;
    if (!isset($kernel) || is_string($kernel)) {
      @trigger_error('Calling ' . __METHOD__ . '() without the $kernel argument is deprecated in drupal:10.3.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3445054', E_USER_DEPRECATED);
      $this->themeName = $kernel;
      $this->kernel = \Drupal::service('kernel');
    }
  }

  /**
@@ -252,11 +261,30 @@ public function get() {
        return $cached;
      }
    }

    // Some theme hook implementations such as the one in Views request a lot of
    // information such as field schemas. These might be broken until an update
    // is run, so we need to build a limited registry while on update.php.
    if ($this->kernel instanceof UpdateKernel) {
      $module_list = $this->moduleHandler->getModuleList();
      $filter_list = array_intersect_key($module_list, ['system' => TRUE]);

      // Call ::build() with only the system module and then revert.
      $this->moduleHandler->setModuleList($filter_list);
      $this->build();
      $this->moduleHandler->setModuleList($module_list);

      // We might have poisoned the cache with only info from 'system'.
      $this->cache->delete("theme_registry:build:modules");
    }
    else {
      $this->build();
      // Only persist it if all modules are loaded to ensure it is complete.
      if ($this->moduleHandler->isLoaded()) {
        $this->setCache();
      }
    }

    return $this->registry[$this->theme->getName()];
  }

+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\Theme\ThemeNegotiatorInterface;

/**
@@ -51,7 +50,8 @@ public function applies(RouteMatchInterface $route_match) {
   * {@inheritdoc}
   */
  public function determineActiveTheme(RouteMatchInterface $route_match) {
    return Settings::get('maintenance_theme') ?: 'claro';
    // The update page always uses Claro to ensure stability.
    return 'claro';
  }

}
+5 −0
Original line number Diff line number Diff line
name: 'Update test with broken theme hook'
type: module
description: 'Support module for update testing.'
package: Testing
version: VERSION
+13 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Hook implementations for the update_test_broken_theme_hook module.
 */

/**
 * Implements hook_theme().
 */
function update_test_broken_theme_hook_theme($existing, $type, $theme, $path) {
  throw new \Exception('This mimics an exception caused by unstable dependencies.');
}
Loading