diff --git a/core/lib/Drupal/Core/Extension/ExtensionList.php b/core/lib/Drupal/Core/Extension/ExtensionList.php index 01eca39..ebc2425 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionList.php +++ b/core/lib/Drupal/Core/Extension/ExtensionList.php @@ -150,6 +150,20 @@ protected function getCacheId() { } /** + * Determines if an extension exists in the filesystem. + * + * @param string $name + * The machine name of the extension. + * + * @return bool + * true if the extension exists (whether installed or not) and false if not. + */ + public function extensionExists($name) { + $extensions = $this->listExtensions(); + return isset($extensions[$name]); + } + + /** * Returns the human readable name of the extension. * * @param string $machine_name diff --git a/core/lib/Drupal/Core/Updater/Module.php b/core/lib/Drupal/Core/Updater/Module.php index a7a1863..f3480df 100644 --- a/core/lib/Drupal/Core/Updater/Module.php +++ b/core/lib/Drupal/Core/Updater/Module.php @@ -54,8 +54,7 @@ public static function getRootDirectoryRelativePath() { public function isInstalled() { // Check if the module exists in the file system, regardless of whether it // is enabled or not. - $modules = \Drupal::state()->get('system.module.files', array()); - return isset($modules[$this->name]); + return \Drupal::service('module_listing')->extensionExists($this->name); } /** diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php index 10463d9..87cf4f6 100644 --- a/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -105,7 +105,7 @@ function __construct($test_id = NULL) { protected function beforePrepareEnvironment() { // Copy/prime extension file lists once to avoid filesystem scans. if (!isset($this->moduleFiles)) { - $this->moduleFiles = \Drupal::state()->get('system.module.files') ?: array(); + $this->moduleFiles = \Drupal::cache('default')->get('system.module.files') ?: array(); $this->themeFiles = \Drupal::state()->get('system.theme.files') ?: array(); } } @@ -227,7 +227,7 @@ protected function setUp() { // Re-inject extension file listings into state, unless the key/value // service was overridden (in which case its storage does not exist yet). if ($this->container->get('keyvalue') instanceof KeyValueMemoryFactory) { - $this->container->get('state')->set('system.module.files', $this->moduleFiles); + $this->container->get('cache.default')->set('system.module.files', $this->moduleFiles); $this->container->get('state')->set('system.theme.files', $this->themeFiles); } diff --git a/core/modules/system/src/Tests/Update/DbDumpTest.php b/core/modules/system/src/Tests/Update/DbDumpTest.php index 7cd099b..cf31d42 100644 --- a/core/modules/system/src/Tests/Update/DbDumpTest.php +++ b/core/modules/system/src/Tests/Update/DbDumpTest.php @@ -125,6 +125,7 @@ protected function setUp() { 'cachetags', 'config', 'cache_bootstrap', + 'cache_default', 'cache_discovery', 'cache_entity', 'file_managed', diff --git a/core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php b/core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php index f9a9b16..e644aa1 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php @@ -20,6 +20,7 @@ /** * @coversDefaultClass \Drupal\Core\Extension\ExtensionList + * @group Extension */ class ExtensionListTest extends UnitTestCase {