diff --git a/core/lib/Drupal/Core/Update/UpdateKernel.php b/core/lib/Drupal/Core/Update/UpdateKernel.php index 1cdf114..7bc4a7c 100755 --- a/core/lib/Drupal/Core/Update/UpdateKernel.php +++ b/core/lib/Drupal/Core/Update/UpdateKernel.php @@ -29,6 +29,15 @@ class UpdateKernel extends DrupalKernel { /** * {@inheritdoc} */ + public function discoverServiceProviders() { + parent::discoverServiceProviders(); + + $this->serviceProviderClasses['app']['update_kernel'] = 'Drupal\Core\Update\UpdaterServiceProvider'; + } + + /** + * {@inheritdoc} + */ protected function initializeContainer() { // Always force a container rebuild. $this->containerNeedsRebuild = TRUE; @@ -39,6 +48,14 @@ protected function initializeContainer() { /** * {@inheritdoc} */ + protected function cacheDrupalContainer(array $container_definition) { + // Don't save this particular container to cache. + return FALSE; + } + + /** + * {@inheritdoc} + */ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) { try { static::bootEnvironment(); diff --git a/core/lib/Drupal/Core/Updater/UpdaterServiceProvider.php b/core/lib/Drupal/Core/Update/UpdaterServiceProvider.php similarity index 65% rename from core/lib/Drupal/Core/Updater/UpdaterServiceProvider.php rename to core/lib/Drupal/Core/Update/UpdaterServiceProvider.php index 5f08874..774ca5a 100644 --- a/core/lib/Drupal/Core/Updater/UpdaterServiceProvider.php +++ b/core/lib/Drupal/Core/Update/UpdaterServiceProvider.php @@ -2,19 +2,19 @@ /** * @file - * Contains \Drupal\Core\Updater\UpdaterServiceProvider. + * Contains \Drupal\Core\Update\UpdaterServiceProvider. */ -namespace Drupal\Core\Updater; +namespace Drupal\Core\Update; use Drupal\Core\DependencyInjection\ContainerBuilder; -use Drupal\Core\DependencyInjection\ServiceProviderInterface; use Drupal\Core\DependencyInjection\ServiceModifierInterface; +use Drupal\Core\DependencyInjection\ServiceProviderInterface; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; /** - * Provides a service provider for the updater environment. + * Ensures for some services that they don't cache. */ class UpdaterServiceProvider implements ServiceProviderInterface, ServiceModifierInterface { @@ -23,7 +23,7 @@ class UpdaterServiceProvider implements ServiceProviderInterface, ServiceModifie */ public function register(ContainerBuilder $container) { $definition = new Definition('Drupal\Core\Cache\NullBackend', ['null']); - $container->setDefinition('cache.backend.null', $definition); + $container->setDefinition('cache.null', $definition); } /** @@ -31,8 +31,12 @@ public function register(ContainerBuilder $container) { */ public function alter(ContainerBuilder $container) { $definition = $container->getDefinition('asset.resolver'); - $argument = new Reference('cache.backend.null'); + $argument = new Reference('cache.null'); $definition->replaceArgument(5, $argument); + + $definition = $container->getDefinition('library.discovery.collector'); + $argument = new Reference('cache.null'); + $definition->replaceArgument(0, $argument); } } diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index fa8104d..935a067 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -186,6 +186,9 @@ public function handle($op, Request $request) { } $title = isset($output['#title']) ? $output['#title'] : $this->t('Drupal database update'); + // Ensure that at least the drupalSettings js is loaded. + $output['#attached']['library'][] = 'core/drupalSettings'; + return $this->bareHtmlPageRenderer->renderBarePage($output, $title, 'maintenance_page', $regions); } diff --git a/core/modules/system/src/Tests/Update/UpdatePathTestJavaScriptTest.php b/core/modules/system/src/Tests/Update/UpdatePathTestJavaScriptTest.php index 74dc424..0061890 100644 --- a/core/modules/system/src/Tests/Update/UpdatePathTestJavaScriptTest.php +++ b/core/modules/system/src/Tests/Update/UpdatePathTestJavaScriptTest.php @@ -20,7 +20,6 @@ class UpdatePathTestJavaScriptTest extends UpdatePathTestBase { protected function setDatabaseDumpFiles() { $this->databaseDumpFiles = [ __DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz', - __DIR__ . '/../../../tests/fixtures/update/drupal-8.update-test-aggregation-disabled.php', ]; } @@ -37,7 +36,22 @@ public function testJavaScriptLoading() { * {@inheritdoc} */ protected function doPreUpdateTests() { - $this->assertRaw('core/misc/drupalSettingsLoader.js', 'Drupal settings found.'); + // Ensure that at least one JS script has drupalSettings in there. + $scripts = $this->xpath('//script'); + $found = FALSE; + foreach ($scripts as $script) { + if (!isset($script['src'])) { + continue; + } + $src = (string) $script['src']; + $file_content = file_get_contents($src); + + if (strpos($file_content, 'window.drupalSettings =') !== FALSE) { + $found = TRUE; + } + } + + $this->assertTrue($found, 'Ensure that the drupalSettingsLoader.js was included in the JS files'); } } diff --git a/core/modules/system/tests/fixtures/update/drupal-8.update-test-aggregation-disabled.php b/core/modules/system/tests/fixtures/update/drupal-8.update-test-aggregation-disabled.php deleted file mode 100644 index 5a6bed6..0000000 --- a/core/modules/system/tests/fixtures/update/drupal-8.update-test-aggregation-disabled.php +++ /dev/null @@ -1,27 +0,0 @@ -select('config') - ->fields('config', ['data']) - ->condition('collection', '') - ->condition('name', 'system.performance') - ->execute() - ->fetchField(); -$cache_settings = unserialize($cache_settings); -$cache_settings['js']['preprocess'] = FALSE; -$connection->update('config') - ->fields([ - 'data' => serialize($cache_settings), - ]) - ->condition('collection', '') - ->condition('name', 'system.performance') - ->execute(); diff --git a/update.php b/update.php index 41998c2..5222b96 100755 --- a/update.php +++ b/update.php @@ -13,8 +13,6 @@ $autoloader = require_once 'autoload.php'; -$GLOBALS['conf']['container_service_providers']['UpdaterServiceProvider'] = 'Drupal\Core\Updater\UpdaterServiceProvider'; - $kernel = new UpdateKernel('prod', $autoloader); $request = Request::createFromGlobals();