diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 7e29d18..ddbf229 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1727,6 +1727,7 @@ function _install_module_batch($module, $module_name, &$context) { function _install_profile_modules_finished($success, $results, $operations) { // Flush all caches to complete the module installation process. Subsequent // installation tasks will now have full access to the profile's modules. + drupal_static_reset('drupal_extension_handler'); drupal_flush_all_caches(); } diff --git a/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php b/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php index 4e2aec5..866015d 100644 --- a/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php @@ -144,6 +144,7 @@ protected function ensureDirectory() { mkdir($this->directory, 0700, TRUE); } chmod($this->directory, 0700); + require_once DRUPAL_ROOT . '/core/includes/file.inc'; file_save_htaccess($this->directory); } diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index da1ce0d..43fa77e 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -38,6 +38,13 @@ public function build(ContainerBuilder $container) { $container->register('request', 'Symfony\Component\HttpFoundation\Request') ->setSynthetic(TRUE); + // The extension_handler and keyvalue services are synthetic because they + // get created by the kernel and injected into the container. + $container->register('extension_handler', 'Drupal\Core\ExtensionHandler') + ->setSynthetic(TRUE); + $container->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueFactory') + ->setSynthetic(TRUE); + // Register the config services // Register active configuration storage. $container @@ -45,7 +52,7 @@ public function build(ContainerBuilder $container) { ->addArgument(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY)); // @todo Replace this with a cache.factory service plus 'config' argument. $container - ->register('cache.config') + ->register('cache.config', 'Drupal\Core\Cache\CacheBackendInterface') ->setFactoryClass('Drupal\Core\Cache\CacheFactory') ->setFactoryMethod('get') ->addArgument('config'); @@ -56,9 +63,9 @@ public function build(ContainerBuilder $container) { ->addArgument(new Reference('cache.config')); // Register configuration object factory. - $container->register('config.subscriber.globalconf', 'Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber'); - $container->register('dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher') - ->addMethodCall('addSubscriber', array(new Reference('config.subscriber.globalconf'))); + $container->register('config.subscriber.globalconf', 'Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber') + ->addTag('kernel.event_subscriber'); + $container->register('config.factory', 'Drupal\Core\Config\ConfigFactory') ->addArgument(new Reference('config.storage')) ->addArgument(new Reference('dispatcher')); @@ -67,12 +74,14 @@ public function build(ContainerBuilder $container) { $container ->register('config.storage.staging', 'Drupal\Core\Config\FileStorage') ->addArgument(config_get_config_directory(CONFIG_STAGING_DIRECTORY)); + $container ->register('state.storage', 'Drupal\Core\KeyValueStore\DatabaseStorage') ->addArgument('state'); $container->register('dispatcher', 'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher') ->addArgument(new Reference('service_container')); + $container->register('resolver', 'Drupal\Core\ControllerResolver') ->addArgument(new Reference('service_container')); $container->register('http_kernel', 'Drupal\Core\HttpKernel') @@ -97,8 +106,7 @@ public function build(ContainerBuilder $container) { ->addArgument(new Reference('database')) ->addArgument(new Reference('lock')); - $container->register('router.dumper', '\Drupal\Core\Routing\MatcherDumper') - + $container->register('router.dumper', 'Drupal\Core\Routing\MatcherDumper') ->addArgument(new Reference('database')); $container->register('router.builder', 'Drupal\Core\Routing\RouteBuilder') ->addArgument(new Reference('router.dumper')) @@ -148,6 +156,7 @@ public function build(ContainerBuilder $container) { ->setScope('request') ->addTag('kernel.event_subscriber'); $container->register('request_close_subscriber', 'Drupal\Core\EventSubscriber\RequestCloseSubscriber') + ->addArgument(new Reference('extension_handler')) ->addTag('kernel.event_subscriber'); $container->register('config_global_override_subscriber', 'Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber') ->addTag('kernel.event_subscriber'); diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 59a04c7..6e9d8b9 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -8,10 +8,8 @@ namespace Drupal\Core; use Drupal\Component\PhpStorage\PhpStorageInterface; -use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheFactory; use Drupal\Core\CoreBundle; -use Drupal\Core\Database\Database; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\ExtensionHandler; use Drupal\Core\KeyValueStore\KeyValueFactory; @@ -54,6 +52,16 @@ class DrupalKernel extends Kernel implements DrupalKernelInterface { protected $storage; /** + * @var \Drupal\Core\KeyValueStore\KeyValueFactory + */ + protected $keyValue; + + /** + * ExtensionHandler instance holding the list of enabled modules. + */ + protected $extensionHandler; + + /** * Constructs a DrupalKernel object. * * @param string $environment @@ -66,37 +74,19 @@ class DrupalKernel extends Kernel implements DrupalKernelInterface { * this value currently. Pass TRUE. * @param array $module_list * (optional) The array of enabled modules as returned by module_list(). - * @param Drupal\Core\Cache\CacheBackendInterface $compilation_index_cache + * @param String $compilation_index_cache_bin * (optional) If wanting to dump a compiled container to disk or use a - * previously compiled container, the cache object for the bin that stores - * the class name of the compiled container. + * previously compiled container, the cache bin that stores the class name + * of the compiled container. */ - public function __construct($environment, $debug, array $module_list = NULL, CacheBackendInterface $compilation_index_cache = NULL) { + public function __construct($environment, $debug, array $module_list = NULL, $compilation_index_cache_bin = NULL) { parent::__construct($environment, $debug); - $this->compilationIndexCache = $compilation_index_cache; + $this->moduleList = $module_list; + $this->compilationIndexCache = isset($compilation_index_cache_bin) ? CacheFactory::get($compilation_index_cache_bin) : NULL; $this->storage = drupal_php_storage('service_container'); - if (isset($module_list)) { - $this->moduleList = $module_list; - } - else { - // @todo This is a temporary measure which will no longer be necessary - // once we have an ExtensionHandler for managing this list. See - // http://drupal.org/node/1331486. - $this->moduleList = module_list(); - } } /** - * ExtensionHandler instance holding the list of enabled modules. - */ - protected $extensionHandler; - - /** - * The database connection used by the ExtensionHandler. - */ - protected $connection; - - /** * Overrides Kernel::init(). */ public function init() { @@ -129,8 +119,7 @@ public function registerBundles() { $bundles = array( new CoreBundle(), ); - - $modules = array_keys($this->extensionHandler->systemList('module_enabled')); + $modules = $this->moduleList ?: array_keys($this->extensionHandler->systemList('module_enabled')); foreach ($modules as $module) { $camelized = ContainerBuilder::camelize($module); $class = "Drupal\\{$module}\\{$camelized}Bundle"; @@ -191,7 +180,9 @@ protected function initializeContainer() { } $this->container->set('kernel', $this); - + // Add our ExtensionHandler and KeyValueFactory as synthetic services. + $this->container->set('extension_handler', $this->extensionHandler); + $this->container->set('keyvalue', $this->keyValue); drupal_container($this->container); if (isset($error)) { @@ -206,15 +197,6 @@ protected function initializeContainer() { */ protected function buildContainer() { $container = $this->getContainerBuilder(); - - // Add our ExtensionHandler and KeyValueFactory as synthetic services. - $container->register('extension_handler', 'Drupal\Core\ExtensionHandler') - ->setSynthetic(TRUE); - $container->set('extension_handler', $this->extensionHandler); - $container->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueFactory') - ->setSynthetic(TRUE); - $container->set('keyvalue', $this->keyValue); - foreach ($this->bundles as $bundle) { $bundle->build($container); } diff --git a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php index 41070c3..62f7293 100644 --- a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\DrupalKernel; +use Drupal\Core\Cache\CacheFactory; use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\DrupalKernel; use Drupal\simpletest\UnitTestBase; @@ -39,16 +40,16 @@ function testCompileDIC() { 'class' => 'Drupal\Component\PhpStorage\MTimeProtectedFileStorage', 'secret' => $GLOBALS['drupal_hash_salt'], ); - $cache = new MemoryBackend('test'); + $conf['cache_classes'] = array('test' => 'Drupal\Core\Cache\MemoryBackend'); $module_enabled = array( 'system' => 'system', 'user' => 'user', ); - $kernel = new DrupalKernel('testing', FALSE, $module_enabled, $cache); + $kernel = new DrupalKernel('testing', FALSE, $module_enabled, 'test'); $kernel->boot(); // Instantiate it a second time and we should get the compiled Container // class. - $kernel = new DrupalKernel('testing', FALSE, $module_enabled, $cache); + $kernel = new DrupalKernel('testing', FALSE, $module_enabled, 'test'); $kernel->boot(); $container = $kernel->getContainer(); $refClass = new ReflectionClass($container); @@ -66,7 +67,7 @@ function testCompileDIC() { $conf['php_storage']['service_container'] = array( 'class' => 'Drupal\Component\PhpStorage\FileReadOnlyStorage', ); - $kernel = new DrupalKernel('testing', FALSE, $module_enabled, $cache); + $kernel = new DrupalKernel('testing', FALSE, $module_enabled, 'test'); $kernel->boot(); $container = $kernel->getContainer(); $refClass = new ReflectionClass($container); @@ -91,12 +92,12 @@ function testCompileDIC() { 'user' => 'user', 'bundle_test' => 'bundle_test', ); - $cache->flush(); - $kernel = new DrupalKernel('testing', FALSE, $module_enabled, $cache); + CacheFactory::get('test')->flush(); + $kernel = new DrupalKernel('testing', FALSE, $module_enabled, 'test'); $kernel->boot(); // Instantiate it a second time and we should still get a ContainerBuilder // class because we are using the read-only PHP storage. - $kernel = new DrupalKernel('testing', FALSE, $module_enabled, $cache); + $kernel = new DrupalKernel('testing', FALSE, $module_enabled, 'test'); $kernel->boot(); $container = $kernel->getContainer(); $refClass = new ReflectionClass($container); diff --git a/index.php b/index.php index 08a07a1..58e6dc4 100644 --- a/index.php +++ b/index.php @@ -28,7 +28,7 @@ drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); // @todo Figure out how best to handle the Kernel constructor parameters. -$kernel = new DrupalKernel('prod', FALSE, NULL, cache('bootstrap')); +$kernel = new DrupalKernel('prod', FALSE, NULL, 'bootstrap'); // Create a request object from the HTTPFoundation. $request = Request::createFromGlobals();