From a33e47e5afb2e38d35f7f8f7516d264ef57a8306 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Mon, 4 Mar 2019 15:23:01 +0000 Subject: [PATCH] Issue #3035361 by claudiu.cristea: Remove usages of drupal_static() & drupal_static_reset() from file_test.module --- .../file/tests/file_test/file_test.module | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module index 0baa0cbd084..35d8299e6f3 100644 --- a/core/modules/file/tests/file_test/file_test.module +++ b/core/modules/file/tests/file_test/file_test.module @@ -319,24 +319,31 @@ function file_test_validator(File $file, $errors) { * * @param string|null $filepath * File path + * @param bool $reset + * (optional) If to reset the internal memory cache. If TRUE is passed, the + * first parameter has no effect. Defaults to FALSE. + * * @return array * If $filepath is NULL, an array of all previous $filepath parameters */ -function file_test_file_scan_callback($filepath = NULL) { - $files = &drupal_static(__FUNCTION__, []); - if (isset($filepath)) { +function file_test_file_scan_callback($filepath = NULL, $reset = FALSE) { + static $files = []; + + if ($reset) { + $files = []; + } + elseif ($filepath) { $files[] = $filepath; } - else { - return $files; - } + + return $files; } /** * Reset static variables used by file_test_file_scan_callback(). */ function file_test_file_scan_callback_reset() { - drupal_static_reset('file_test_file_scan_callback'); + file_test_file_scan_callback(NULL, TRUE); } /**