diff --git a/core/lib/Drupal/Core/Extension/ExtensionList.php b/core/lib/Drupal/Core/Extension/ExtensionList.php index 6e78072..c9a2736 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionList.php +++ b/core/lib/Drupal/Core/Extension/ExtensionList.php @@ -106,6 +106,10 @@ public function __construct($root, $type, CacheBackendInterface $cache, InfoPars public function reset() { $this->extensions = NULL; $this->cache->delete($this->getCacheId()); + $this->extensionInfo = NULL; + $this->cache->delete("system.{$this->type}.info"); + $this->fileNames = NULL; + \Drupal::state()->delete("system.{$this->type}.files"); return $this; } @@ -166,11 +170,7 @@ public function listExtensions() { return $extensions; } $extensions = $this->doListExtensions(); - $this->cache->get($this->getCacheId()); - - $this->recalculateInfo(); - $this->recalculateFilenames(); - + $this->cache->set($this->getCacheId(), $extensions); $this->extensions = $extensions; return $this->extensions; } @@ -202,7 +202,7 @@ protected function doListExtensions() { $extensions = $this->doScanExtensions($listing); // Read info files for each extension. - foreach ($extensions as $key => $extension) { + foreach ($extensions as $name => $extension) { // Look for the info file. $extension->info = $this->infoParser->parse($extension->getPathname()); @@ -211,12 +211,12 @@ protected function doListExtensions() { $extension->info['mtime'] = $extension->getMTime(); // Merge in defaults and save. - $extensions[$key]->info = $extension->info + $this->defaults; + $extensions[$name]->info = $extension->info + $this->defaults; // Invoke hook_system_info_alter() to give installed modules a chance to // modify the data in the .info.yml files if necessary. // @todo Remove $type argument, obsolete with $module->getType(). - $this->moduleHandler->alter('system_info', $extensions[$key]->info, $extensions[$key], $this->type); + $this->moduleHandler->alter('system_info', $extensions[$name]->info, $extensions[$name], $this->type); } return $extensions; @@ -240,7 +240,6 @@ protected function doListExtensions() { * array is returned. */ public function getInfo($name = NULL) { - $this->extensionInfo; if (!isset($this->extensionInfo)) { if ($cache = $this->cache->get("system.{$this->type}.info")) { $info = $cache->data; @@ -258,10 +257,8 @@ public function getInfo($name = NULL) { protected function recalculateInfo() { $info = []; - foreach ($this->listExtensions() as $extension_name => $filename) { - if (isset($data[$extension_name])) { - $info[$extension_name] = $data[$extension_name]->info; - } + foreach ($this->listExtensions() as $name => $extension) { + $info[$name] = $extension->info; } // Store the module information in cache. This cache is cleared by // calling system_rebuild_module_data(), for example, when listing @@ -279,7 +276,7 @@ protected function recalculateInfo() { public function getFilenames() { if (!isset($this->fileNames)) { $file_names = \Drupal::state()->get("system.{$this->type}.files"); - if (!isset($files)) { + if (!isset($file_names)) { $file_names = $this->recalculateFilenames(); } $this->fileNames = $file_names; @@ -291,8 +288,8 @@ protected function recalculateFilenames() { $file_names = []; $extensions = $this->listExtensions(); ksort($extensions); - foreach ($extensions as $extension_name => $extension) { - $file_names[$extension_name] = $extension->getPathname(); + foreach ($extensions as $name => $extension) { + $file_names[$name] = $extension->getPathname(); } \Drupal::state()->set("system.{$this->type}.files", $file_names); return $file_names; diff --git a/core/lib/Drupal/Core/Extension/ModuleExtensionList.php b/core/lib/Drupal/Core/Extension/ModuleExtensionList.php index 3561b28..9e7763e 100644 --- a/core/lib/Drupal/Core/Extension/ModuleExtensionList.php +++ b/core/lib/Drupal/Core/Extension/ModuleExtensionList.php @@ -129,7 +129,6 @@ protected function doListExtensions() { $module->weight = isset($installed_modules[$name]) ? $installed_modules[$name] : 0; $module->status = (int) isset($installed_modules[$name]); $module->schema_version = SCHEMA_UNINSTALLED; - $files[$name] = $module->getPathname(); } $extensions = $this->moduleHandler->buildModuleDependencies($extensions);