From d1e52e008923a4e959959069d6e992cb8259fd64 Mon Sep 17 00:00:00 2001
From: Katherine Bailey <katherine@katbailey.net>
Date: Mon, 23 Jul 2012 21:06:56 -0700
Subject: [PATCH] Various cleanups

---
 core/includes/bootstrap.inc                    |  1 -
 core/includes/install.core.inc                 |  2 +-
 core/includes/update.inc                       | 15 ++++-----------
 core/lib/Drupal/Core/CoreBundle.php            |  1 +
 .../DependencyInjection/ContainerBuilder.php   |  4 ----
 core/lib/Drupal/Core/DrupalKernel.php          | 18 +++++++++++++-----
 core/lib/Drupal/Core/HttpKernel.php            |  3 ---
 .../Drupal/Core/Language/LanguageManager.php   |  2 +-
 .../locale/Tests/LocaleUninstallTest.php       |  3 +++
 9 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 71a03a6eb93b..ee7240ee4c77 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -6,7 +6,6 @@
 use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
 use Symfony\Component\DependencyInjection\Container;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\HttpFoundation\Request;
 use Drupal\Core\Language\Language;
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 6e6658ffab6d..e51b458e3609 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -275,7 +275,7 @@ function install_begin_request(&$install_state) {
   include_once DRUPAL_ROOT . '/core/includes/session.inc';
 
   // Set up $language, so t() caller functions will still work.
-  //drupal_language_initialize();
+  drupal_language_initialize();
 
   require_once DRUPAL_ROOT . '/core/includes/ajax.inc';
   // Override the module list with a minimal set of modules.
diff --git a/core/includes/update.inc b/core/includes/update.inc
index 1a1d7f646152..0902036a3a37 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -247,23 +247,16 @@ function update_prepare_d8_language() {
 
     // Update the 'language_default' system variable, if configured.
     $language_default = variable_get('language_default');
-    if (!empty($language_default) && isset($language_default->language)) {
-      $language_default->langcode = $language_default->language;
+    if (!empty($language_default) && (isset($language_default->langcode) || isset($language_default->language))) {
+      if (!isset($language_default->langcode)) {
+        $language_default->langcode = $language_default->language;
+      }
       unset($language_default->language);
       // In D8, the 'language_default' is not anymore an object, but an array,
       // so make sure that the new value that is saved into this variable is an
       // array.
       variable_set('language_default', (array) $language_default);
      }
-     else {
-      variable_set('language_default', array(
-        'langcode' => 'en',
-        'name' => 'English',
-        'direction' => 0,
-        'weight' => 0,
-        'locked' => 0,
-      ));
-     }
 
     // Adds the locked column and saves the special languages.
     if (!db_field_exists('language', 'locked')) {
diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php
index aeb89524b4c7..c5f98a340fcb 100644
--- a/core/lib/Drupal/Core/CoreBundle.php
+++ b/core/lib/Drupal/Core/CoreBundle.php
@@ -19,6 +19,7 @@ class CoreBundle extends Bundle
 {
   public function build(ContainerBuilder $container) {
 
+    // Add a 'request' scope for services that depend on the Request object.
     $container->addScope(new Scope('request'));
 
     $container->register('dispatcher', 'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher')
diff --git a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php
index 75a31bf82daa..dfccb7465850 100644
--- a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php
+++ b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php
@@ -30,10 +30,6 @@ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig:
   public function compile() {
     $this->compiler->compile($this);
     $this->parameterBag->resolve();
-    // TODO: The line below is commented out because there is code that calls
-    // the set() method on the container after it has been built - that method
-    // throws an exception if the container's parameters have been frozen.
-    //$this->parameterBag = new FrozenParameterBag($this->parameterBag->all());
   }
 
 }
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 7d372ade5f39..20adda474448 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -28,7 +28,8 @@ public function registerBundles() {
 
     $modules = array_keys(system_list('module_enabled'));
     foreach ($modules as $module) {
-      $class = "\Drupal\\{$module}\\{$module}Bundle";
+      $camelized = ContainerBuilder::camelize($module);
+      $class = "\Drupal\\{$module}\\{$camelized}Bundle";
       if (class_exists($class)) {
         $bundles[] = new $class();
       }
@@ -41,6 +42,9 @@ public function registerBundles() {
    * Initializes the service container.
    */
   protected function initializeContainer() {
+    // @todo We should be compiling the container and dumping to php so we don't
+    // have to recompile every time. There is a separate issue for this, see
+    // http://drupal.org/node/1668892.
     $this->container = $this->buildContainer();
     $this->container->set('kernel', $this);
     drupal_container($this->container);
@@ -73,10 +77,14 @@ protected function getContainerBuilder() {
     return new ContainerBuilder(new ParameterBag($this->getKernelParameters()));
   }
 
+  /**
+   * This method is part of the KernelInterface interface, but takes an object
+   * implementing LoaderInterface as its only parameter. This is part of the
+   * Config compoment from Symfony, which is not provided by Drupal core.
+   *
+   * Modules wishing to provide an extension to this class which uses this
+   * method are responsible for ensuring the Config component exists.
+   */
   public function registerContainerConfiguration(LoaderInterface $loader) {
-    // We have to define this method because it's not defined in the base class
-    // but is part of the KernelInterface interface. However, the LoaderInterface
-    // class is part of the config component, which we are not using, so this
-    // is badness :-/
   }
 }
diff --git a/core/lib/Drupal/Core/HttpKernel.php b/core/lib/Drupal/Core/HttpKernel.php
index e395ea59cc5e..d8031f3c6cc0 100644
--- a/core/lib/Drupal/Core/HttpKernel.php
+++ b/core/lib/Drupal/Core/HttpKernel.php
@@ -17,9 +17,6 @@
 
 /**
  * This HttpKernel is used to manage scope changes of the DI container.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  */
 class HttpKernel extends BaseHttpKernel
 {
diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php
index ae2a8d795954..a2bf31ef86c3 100644
--- a/core/lib/Drupal/Core/Language/LanguageManager.php
+++ b/core/lib/Drupal/Core/Language/LanguageManager.php
@@ -14,7 +14,7 @@
  */
 class LanguageManager {
 
-  private $container;
+  private $request;
 
   public function __construct(Request $request = NULL) {
     $this->request = $request;
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
index ef34ce7f2be7..7df750383fe8 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
@@ -47,6 +47,9 @@ function testUninstallProcess() {
     );
     language_save($language);
 
+    // Make sure the language interface object gets freshly initialized.
+    drupal_static_reset('language_manager');
+
     // Check the UI language.
     drupal_language_initialize();
     $this->assertEqual(language_manager(LANGUAGE_TYPE_INTERFACE)->langcode, $this->langcode, t('Current language: %lang', array('%lang' => language_manager(LANGUAGE_TYPE_INTERFACE)->langcode)));
-- 
GitLab