diff -u b/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test --- b/modules/simpletest/tests/bootstrap.test +++ b/modules/simpletest/tests/bootstrap.test @@ -415,13 +415,26 @@ $non_existing_module = uniqid("", TRUE); // Searching for an item that does not exist returns NULL. + // Set a custom error handler so we can ignore the file not found error. + set_error_handler(function($severity, $message, $file, $line) { + // Skip error handling if this is a "file not found" error. + if (strstr($message, 'is missing from the file system:')) { + cache_set('get_filename_test_triggered_error', TRUE); + return; + } + throw new \ErrorException($message, 0, $severity, $file, $line); + }); + $this->assertNull(drupal_get_filename('module', $non_existing_module), 'Searching for an item that does not exist returns NULL.'); + $this->assertTrue(cache_get('get_filename_test_triggered_error'), 'Searching for an item that does not exist triggers an error.'); + // Restore the original error handler. + restore_error_handler(); $this->assertNull(drupal_get_filename('module', $non_existing_module), 'Searching for an item that does not exist returns NULL.'); // Get the bad records static from drupal_get_filename. - $bad = &drupal_static('drupal_get_filename:bad'); + $bad = &drupal_static('drupal_get_filename:missing'); // Searching for an item that does not exist creates a static record in drupal_get_filename. - $this->assertTrue($bad['module'][$non_existing_module], 'Searching for an item that does not exist creates a static record in drupal_get_filename.'); + $this->assertTrue($missing['module'][$non_existing_module], 'Searching for an item that does not exist creates a static record in drupal_get_filename.'); } } diff -u b/modules/system/system.admin.inc b/modules/system/system.admin.inc --- b/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -136,7 +136,7 @@ function system_themes_page() { // Clean up the bootstrap "missing files" cache when listing themes. drupal_static_reset('drupal_get_filename:missing'); - cache_clear_all('drupal_get_filename:missing'); + cache_clear_all('*', 'drupal_get_filename:missing', TRUE); // Get current list of themes. $themes = system_rebuild_theme_data(); @@ -794,7 +794,7 @@ function system_modules($form, $form_state = array()) { // Clean up the bootstrap "missing modules" cache when listing modules. drupal_static_reset('drupal_get_filename:missing'); - cache_clear_all('drupal_get_filename:missing'); + cache_clear_all('*', 'drupal_get_filename:missing', TRUE); // Get current list of modules. $files = system_rebuild_module_data();