summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2011-10-16 16:37:18 (GMT)
committerDries2011-10-16 16:38:04 (GMT)
commitf98273f975d4f1b17967d893c0f28ff3ef41c51a (patch)
treeccba59b886688410a2d8ac3726c22901a09fbd5b
parentfb97b53f9469219f3f801551c6bb9b461e97ce1b (diff)
- Patch #1081266 by mfb: avoid re-scanning module directory when multiple modules are missing.
-rw-r--r--includes/bootstrap.inc25
1 files changed, 14 insertions, 11 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index bc5d5a3..9505870 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -850,7 +850,7 @@ function drupal_settings_initialize() {
function drupal_get_filename($type, $name, $filename = NULL) {
// The location of files will not change during the request, so do not use
// drupal_static().
- static $files = array();
+ static $files = array(), $dirs = array();
if (!isset($files[$type])) {
$files[$type] = array();
@@ -896,16 +896,19 @@ function drupal_get_filename($type, $name, $filename = NULL) {
$extension = $type;
}
- if (!function_exists('drupal_system_listing')) {
- require_once DRUPAL_ROOT . '/includes/common.inc';
- }
- // Scan the appropriate directories for all files with the requested
- // extension, not just the file we are currently looking for. This
- // prevents unnecessary scans from being repeated when this function is
- // called more than once in the same page request.
- $matches = drupal_system_listing("/^" . DRUPAL_PHP_FUNCTION_PATTERN . "\.$extension$/", $dir, 'name', 0);
- foreach ($matches as $matched_name => $file) {
- $files[$type][$matched_name] = $file->uri;
+ if (!isset($dirs[$dir][$extension])) {
+ $dirs[$dir][$extension] = TRUE;
+ if (!function_exists('drupal_system_listing')) {
+ require_once DRUPAL_ROOT . '/includes/common.inc';
+ }
+ // Scan the appropriate directories for all files with the requested
+ // extension, not just the file we are currently looking for. This
+ // prevents unnecessary scans from being repeated when this function is
+ // called more than once in the same page request.
+ $matches = drupal_system_listing("/^" . DRUPAL_PHP_FUNCTION_PATTERN . "\.$extension$/", $dir, 'name', 0);
+ foreach ($matches as $matched_name => $file) {
+ $files[$type][$matched_name] = $file->uri;
+ }
}
}
}