diff -u b/core/includes/config.inc b/core/includes/config.inc --- b/core/includes/config.inc +++ b/core/includes/config.inc @@ -76,7 +76,7 @@ * A configuration object. */ function config($name) { - return drupal_container()->get('config.factory')->get($name)->load(); + return drupal_container()->get('config.factory')->get()->setName($name)->load(); } /** diff -u b/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php --- b/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -26,7 +26,7 @@ protected $container; - protected $configObjects = array(); + protected $configObject; public function __construct(ContainerBuilder $container) { $this->container = $container; @@ -41,8 +41,8 @@ * @return Drupal\Core\Config\ConfigObject * A configuration object with the given $name. */ - public function get($name) { - // "Caching" the instantiated objects per name cuts off a fair amount of CPU + public function get() { + // "Caching" the instantiated config object cuts off a fair amount of CPU // time and memory. Only the data within the configuration object changes, // so the additional cost of instantiating duplicate objects can be happily // avoided. It is not uncommon for a configuration object to be retrieved @@ -60,10 +60,9 @@ // ContainerBuilder involves plenty of function calls (which are known to // be slow in PHP). - if (isset($this->configObjects[$name])) { - return $this->configObjects[$name]; + if (!is_object($this->configObject)) { + $class = $this->container->getParameter('config.object'); + $this->configObject = new $class($this->container->get('config.manager')); } - $class = $this->container->getParameter('config.object'); - $this->configObjects[$name] = new $class($this->container->get('config.manager')); - return $this->configObjects[$name]->setName($name); + return $this->configObject; } }