Commit bb05d952 authored by catch's avatar catch

Issue #2176669 by alexpott: Stop persisting the url_generator.

parent 2a228e60
......@@ -274,8 +274,6 @@ services:
calls:
- [setRequest, ['@?request']]
- [setContext, ['@?router.request_context']]
tags:
- { name: persist }
link_generator:
class: Drupal\Core\Utility\LinkGenerator
arguments: ['@url_generator', '@module_handler', '@language_manager']
......
......@@ -108,6 +108,7 @@ function update_prepare_d8_bootstrap() {
// Enable UpdateServiceProvider service overrides.
// @see update_flush_all_caches()
$GLOBALS['conf']['container_service_providers']['UpdateServiceProvider'] = 'Drupal\Core\DependencyInjection\UpdateServiceProvider';
$GLOBALS['conf']['update_service_provider_overrides'] = TRUE;
// Check whether settings.php needs to be rewritten.
$settings_exist = !empty($GLOBALS['config_directories']);
......
......@@ -7,9 +7,8 @@
namespace Drupal\Core\DependencyInjection;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpFoundation\Request;
/**
* ServiceProvider class for update.php service overrides.
......@@ -18,33 +17,50 @@
* and required to prevent various services from trying to retrieve data from
* storages that do not exist yet.
*/
class UpdateServiceProvider implements ServiceProviderInterface {
class UpdateServiceProvider implements ServiceProviderInterface, ServiceModifierInterface {
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
// Disable the Lock service.
$container
->register('lock', 'Drupal\Core\Lock\NullLockBackend');
// Prevent config from accessing {cache_config}.
// @see $conf['cache_classes'], update_prepare_d8_bootstrap()
$container
->register('config.storage', 'Drupal\Core\Config\FileStorage')
->addArgument(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY));
$container->register('module_handler', 'Drupal\Core\Extension\UpdateModuleHandler')
->addArgument('%container.modules%');
$container
->register("cache_factory", 'Drupal\Core\Cache\MemoryBackendFactory');
$container
->register('router.builder', 'Drupal\Core\Routing\RouteBuilderStatic');
$container->register('theme_handler', 'Drupal\Core\Extension\ThemeHandler')
->addArgument(new Reference('config.factory'))
->addArgument(new Reference('module_handler'))
->addArgument(new Reference('cache.cache'))
->addArgument(new Reference('info_parser'));
if (!empty($GLOBALS['conf']['update_service_provider_overrides'])) {
// Disable the Lock service.
$container
->register('lock', 'Drupal\Core\Lock\NullLockBackend');
// Prevent config from accessing {cache_config}.
// @see $conf['cache_classes'], update_prepare_d8_bootstrap()
$container
->register('config.storage', 'Drupal\Core\Config\FileStorage')
->addArgument(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY));
$container->register('module_handler', 'Drupal\Core\Extension\UpdateModuleHandler')
->addArgument('%container.modules%');
$container
->register('cache_factory', 'Drupal\Core\Cache\MemoryBackendFactory');
$container
->register('router.builder', 'Drupal\Core\Routing\RouteBuilderStatic');
$container->register('theme_handler', 'Drupal\Core\Extension\ThemeHandler')
->addArgument(new Reference('config.factory'))
->addArgument(new Reference('module_handler'))
->addArgument(new Reference('cache.cache'))
->addArgument(new Reference('info_parser'));
}
}
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
// Ensure that URLs generated for the home and admin pages don't have
// 'update.php' in them.
$request = Request::createFromGlobals();
$definition = $container->getDefinition('url_generator');
$definition->addMethodCall('setBasePath', array(str_replace('/core', '', $request->getBasePath()) . '/'));
// We need to set the script path to an empty string since the value
// determined by \Drupal\Core\Routing\UrlGenerator::setRequest() is invalid
// once '/core' has been removed from the base path.
$definition->addMethodCall('setScriptPath', array(''));
}
}
......@@ -86,7 +86,7 @@ function update_helpful_links() {
* while updates are running.
*/
function update_flush_all_caches() {
unset($GLOBALS['conf']['container_service_providers']['UpdateServiceProvider']);
$GLOBALS['conf']['update_service_provider_overrides'] = FALSE;
\Drupal::service('kernel')->updateModules(\Drupal::moduleHandler()->getModuleList());
// No updates to run, so caches won't get flushed later. Clear them now.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment