diff --git a/core/includes/file.inc b/core/includes/file.inc index c09743e..87f6689 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -199,9 +199,12 @@ * @see hook_stream_wrappers_alter() */ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) { - $wrappers_storage = &drupal_static(__FUNCTION__); + $wrappers_storage = &drupal_static(__FUNCTION__, array()); - if (!isset($wrappers_storage)) { + if (empty($wrappers_storage)) { + // Initialize $wrappers_storage, so that we are not calling this method + // repeatedly if no stream wrappers exist. + $wrappers_storage[STREAM_WRAPPERS_ALL] = array(); $wrappers = array(); if (\Drupal::hasService('module_handler')) { $wrappers = \Drupal::moduleHandler()->invokeAll('stream_wrappers'); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index 64b55cb..d10ce9f 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -453,16 +453,10 @@ protected function unregisterStreamWrapper($scheme, $type) { unset($this->streamWrappers[$scheme]); // @todo Revamp Drupal's stream wrapper API for D8. // @see https://drupal.org/node/2028109 - $wrappers = &drupal_static('file_get_stream_wrappers'); - // If no module implementing hook_stream_wrappers() is enabled and a call to - // drupal_static_reset() is followed by a call to file_get_stream_wrappers(), - // then its static variable will be NULL, in which case no further action is - // required. - if (isset($wrappers)) { - foreach ($wrappers as $filter => $schemes) { - if (is_int($filter) && (($filter & $type) == $filter)) { - unset($wrappers[$filter][$scheme]); - } + $wrappers = &drupal_static('file_get_stream_wrappers', array()); + foreach ($wrappers as $filter => $schemes) { + if (is_int($filter) && (($filter & $type) == $filter)) { + unset($wrappers[$filter][$scheme]); } } }