Commit 344522d5 authored by catch's avatar catch

Issue #3017105 by alexpott: Deprecate system_list_reset()

parent ad902620
...@@ -44,8 +44,15 @@ function system_list($type) { ...@@ -44,8 +44,15 @@ function system_list($type) {
/** /**
* Resets all system_list() caches. * Resets all system_list() caches.
*
* @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. There
* is no direct replacement. Call each
* \Drupal::service('extension.list.TYPE')->reset() as necessary.
*
* @see https://www.drupal.org/node/2709919
*/ */
function system_list_reset() { function system_list_reset() {
@trigger_error("system_list_reset() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. There is no direct replacement. Call each \Drupal::service('extension.list.TYPE')->reset() as necessary. See https://www.drupal.org/node/2709919.", E_USER_DEPRECATED);
\Drupal::service('extension.list.profile')->reset(); \Drupal::service('extension.list.profile')->reset();
\Drupal::service('extension.list.module')->reset(); \Drupal::service('extension.list.module')->reset();
\Drupal::service('extension.list.theme_engine')->reset(); \Drupal::service('extension.list.theme_engine')->reset();
......
...@@ -112,10 +112,11 @@ function update_check_requirements() { ...@@ -112,10 +112,11 @@ function update_check_requirements() {
*/ */
function update_set_schema($module, $schema_version) { function update_set_schema($module, $schema_version) {
\Drupal::keyValue('system.schema')->set($module, $schema_version); \Drupal::keyValue('system.schema')->set($module, $schema_version);
// system_list_reset() is in module.inc but that would only be available \Drupal::service('extension.list.profile')->reset();
// once the variable bootstrap is done. \Drupal::service('extension.list.module')->reset();
require_once __DIR__ . '/module.inc'; \Drupal::service('extension.list.theme_engine')->reset();
system_list_reset(); \Drupal::service('extension.list.theme')->reset();
drupal_static_reset('drupal_get_installed_schema_version');
} }
/** /**
......
...@@ -67,7 +67,6 @@ public function testInstallUninstall() { ...@@ -67,7 +67,6 @@ public function testInstallUninstall() {
// Export active config to sync. // Export active config to sync.
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync')); $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
system_list_reset();
$this->resetAll(); $this->resetAll();
// Delete all entities provided by modules that prevent uninstallation. For // Delete all entities provided by modules that prevent uninstallation. For
...@@ -87,7 +86,6 @@ public function testInstallUninstall() { ...@@ -87,7 +86,6 @@ public function testInstallUninstall() {
// Purge the field data. // Purge the field data.
field_purge_batch(1000); field_purge_batch(1000);
system_list_reset();
$all_modules = system_rebuild_module_data(); $all_modules = system_rebuild_module_data();
// Ensure that only core required modules and the install profile can not be uninstalled. // Ensure that only core required modules and the install profile can not be uninstalled.
......
...@@ -66,6 +66,13 @@ public function testUpdateHooks() { ...@@ -66,6 +66,13 @@ public function testUpdateHooks() {
$this->assertEqual(drupal_get_installed_schema_version('update_test_schema', TRUE), 8001); $this->assertEqual(drupal_get_installed_schema_version('update_test_schema', TRUE), 8001);
// Ensure the index was added for column a. // Ensure the index was added for column a.
$this->assertTrue($connection->schema()->indexExists('update_test_schema_table', 'test'), 'Version 8001 of the update_test_schema module is installed.'); $this->assertTrue($connection->schema()->indexExists('update_test_schema_table', 'test'), 'Version 8001 of the update_test_schema module is installed.');
// Test the update_set_schema() utility function.
require_once $this->root . '/core/includes/update.inc';
update_set_schema('update_test_schema', 8003);
// Ensure schema has changed.
$this->assertEqual(drupal_get_installed_schema_version('update_test_schema'), 8003);
} }
} }
...@@ -43,6 +43,7 @@ protected function setUp() { ...@@ -43,6 +43,7 @@ protected function setUp() {
* Tests installing a theme. * Tests installing a theme.
* *
* @expectedDeprecation system_list() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal::service('theme_handler')->listInfo() instead. See https://www.drupal.org/node/2709919 * @expectedDeprecation system_list() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal::service('theme_handler')->listInfo() instead. See https://www.drupal.org/node/2709919
* @expectedDeprecation system_list_reset() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. There is no direct replacement. Call each \Drupal::service('extension.list.TYPE')->reset() as necessary. See https://www.drupal.org/node/2709919.
*/ */
public function testSystemList() { public function testSystemList() {
// Verifies that no themes are listed by default. // Verifies that no themes are listed by default.
...@@ -63,6 +64,9 @@ public function testSystemList() { ...@@ -63,6 +64,9 @@ public function testSystemList() {
$this->assertEmpty(system_list('theme')); $this->assertEmpty(system_list('theme'));
$this->assertEmpty(system_list('filepaths')); $this->assertEmpty(system_list('filepaths'));
// Call system_list_reset() to test deprecation and ensure it is not broken.
system_list_reset();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment