Commit 3b427fae authored by webchick's avatar webchick

#341140 follow-up by JohnAlbin and chx: drupal_get_filename() fails for...

#341140 follow-up by JohnAlbin and chx:  drupal_get_filename() fails for PHPTemplate themes when database is down.
parent 0e44b42b
...@@ -677,14 +677,15 @@ function drupal_get_filename($type, $name, $filename = NULL) { ...@@ -677,14 +677,15 @@ function drupal_get_filename($type, $name, $filename = NULL) {
$mask = "/$name\.$type$/"; $mask = "/$name\.$type$/";
} }
if (function_exists('drupal_system_listing')) { if (!function_exists('drupal_system_listing')) {
require_once DRUPAL_ROOT . '/includes/common.inc';
}
$matches = drupal_system_listing($mask, $dir, 'name', 0); $matches = drupal_system_listing($mask, $dir, 'name', 0);
if (!empty($matches[$name]->uri)) { if (!empty($matches[$name]->uri)) {
$files[$type][$name] = $matches[$name]->uri; $files[$type][$name] = $matches[$name]->uri;
} }
} }
} }
}
if (isset($files[$type][$name])) { if (isset($files[$type][$name])) {
return $files[$type][$name]; return $files[$type][$name];
......
...@@ -4499,13 +4499,10 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) ...@@ -4499,13 +4499,10 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)
$searchdir[] = "$config/$directory"; $searchdir[] = "$config/$directory";
} }
// If the database is not available, we can't use function_exists(), so // Get current list of items
// we load the file_scan_directory function definition manually.
if (!function_exists('file_scan_directory')) { if (!function_exists('file_scan_directory')) {
require_once DRUPAL_ROOT . '/includes/file.inc'; require_once DRUPAL_ROOT . '/includes/file.inc';
} }
// Get current list of items
foreach ($searchdir as $dir) { foreach ($searchdir as $dir) {
$files = array_merge($files, file_scan_directory($dir, $mask, array('key' => $key, 'min_depth' => $min_depth))); $files = array_merge($files, file_scan_directory($dir, $mask, array('key' => $key, 'min_depth' => $min_depth)));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment