8.2.x bootstrap.inc drupal_static_reset($name = NULL)
8.0.x bootstrap.inc drupal_static_reset($name = NULL)
8.1.x bootstrap.inc drupal_static_reset($name = NULL)
8.3.x bootstrap.inc drupal_static_reset($name = NULL)
7.x bootstrap.inc drupal_static_reset($name = NULL)

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

Parameters

$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.

111 calls to drupal_static_reset()
block_page_build in modules/block/block.module
Implements hook_page_build().
book_node_delete in modules/book/book.module
Implements hook_node_delete().
BootstrapGetFilenameTestCase::testDrupalGetFilename in modules/simpletest/tests/bootstrap.test
Test that drupal_get_filename() works correctly when the file is not found in the database.
BootstrapIPAddressTestCase::setUp in modules/simpletest/tests/bootstrap.test
Sets up a Drupal site for running functional and integration tests.
BootstrapIPAddressTestCase::tearDown in modules/simpletest/tests/bootstrap.test
Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix.

... See full list

File

includes/bootstrap.inc, line 3702
Functions that need to be loaded on every Drupal request.

Code

function drupal_static_reset($name = NULL) {
  drupal_static($name, NULL, TRUE);
}

Comments

fuzzy76’s picture

It is probably never a good idea to call this function without a name. In theory it should be a safe operation, but in reality a lot of modules will freak out if their static variables go missing.

heathdutton’s picture

The static variables wouldn't go missing, they would be reset to their defaults. Presumably if drupal_static is used as a short-term caching mechanism in all the methods (as intended) this is fine. It's good to be cautious, but if you are running out of ram drupal_static_reset() could be the best viable option.

Xenza’s picture

Modules often use drupal_static to keep track of data from multiple calls to the same function in the current request.
As an example, please see how it is used in views_ui here: https://api.drupal.org/api/views/includes!admin.inc/function/views_ui_ad...