function drupal_static_reset

Same name and namespace in other branches
  1. 11.x core/includes/bootstrap.inc \drupal_static_reset()
  2. 10 core/includes/bootstrap.inc \drupal_static_reset()
  3. 9 core/includes/bootstrap.inc \drupal_static_reset()
  4. 8.9.x core/includes/bootstrap.inc \drupal_static_reset()
  5. 7.x includes/bootstrap.inc \drupal_static_reset()

Resets one or all centrally stored static variable(s).

Parameters

string $name: Name of the static variable to reset. Omit to reset all variables. Resetting all variables should only be used, for example, for running unit tests with a clean environment.

8 calls to drupal_static_reset()
drupal_flush_all_caches in core/includes/common.inc
Re-initializes the entire system.
FunctionalTestSetupTrait::prepareEnvironment in core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
Prepares the current environment for running the test.
KernelTestBase::tearDown in core/tests/Drupal/KernelTests/KernelTestBase.php
ListItemBase::submitFieldStorageUpdate in core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
Resets the static variable on field storage update.
LocalePluralFormatTest::testGetPluralFormat in core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
Tests locale_get_plural() and \Drupal::translation()->formatPlural().

... See full list

1 string reference to 'drupal_static_reset'
KernelTestBase::tearDown in core/tests/Drupal/KernelTests/KernelTestBase.php

File

core/includes/bootstrap.inc, line 428

Code

function drupal_static_reset($name = NULL) : void {
  switch ($name) {
    case 'locale_translation_get_projects':
      @trigger_error('Calling drupal_static_reset() with "locale_translation_get_projects" as argument is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service("cache.memory")->delete("locale_get_projects") instead. See https://www.drupal.org/node/3569330', E_USER_DEPRECATED);
      if (\Drupal::hasService('cache.memory')) {
        \Drupal::service('cache.memory')->delete('locale_get_projects');
      }
      break;

    case 'locale_translation_project_list':
      @trigger_error("Using drupal_static_reset() with 'locale_translation_project_list' as argument is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. See https://www.drupal.org/node/3037033", E_USER_DEPRECATED);
      break;

    case 'locale_translation_get_file_history':
      @trigger_error('Calling drupal_static_reset() with "locale_translation_get_file_history" as argument is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service("cache.memory")->invalidateTags(["locale_current_import"]) instead. See https://www.drupal.org/node/3037162', E_USER_DEPRECATED);
      \Drupal::service('cache.memory')->invalidateTags([
        'locale_current_import',
      ]);
      break;

    case 'filter_formats':
      @trigger_error("Using drupal_static_reset() with 'filter_formats' as argument is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. No replacement is provided. See https://www.drupal.org/node/3035368", E_USER_DEPRECATED);
      break;

    case 'file_get_file_references':
    case 'file_get_file_references:field_columns':
      @trigger_error("Calling drupal_static_reset() with \"{$name}\" as argument is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service('cache.memory')->invalidateTags(['file_references']) instead. See https://www.drupal.org/node/3573884", E_USER_DEPRECATED);
      \Drupal::service('cache.memory')->invalidateTags([
        'file_references',
      ]);
      break;

  }
  drupal_static($name, NULL, TRUE);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.