Skip to content
Snippets Groups Projects
Commit 9ca87238 authored by Angie Byron's avatar Angie Byron
Browse files

#358815 by David_Rothstein, meatsack, and John Morahan: Fixed performance of...

#358815 by David_Rothstein, meatsack, and John Morahan: Fixed performance of drupal_get_install_files() with large file trees.
parent 53748ab5
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -658,12 +658,14 @@ function drupal_get_filename($type, $name, $filename = NULL) {
// when a database connection fails.
else {
try {
$file = db_query("SELECT filename FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField();
if (file_exists($file)) {
$files[$type][$name] = $file;
if (function_exists('db_query')) {
$file = db_query("SELECT filename FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField();
if (file_exists($file)) {
$files[$type][$name] = $file;
}
}
}
catch (PDOException $e) {
catch (Exception $e) {
// The database table may not exist because Drupal is not yet installed,
// or the database might be down. We have a fallback for this case so we
// hide the error completely.
......@@ -675,21 +677,25 @@ function drupal_get_filename($type, $name, $filename = NULL) {
$dir = $type . 's';
if ($type == 'theme_engine') {
$dir = 'themes/engines';
$mask = "/$name\.engine$/";
$extension = 'engine';
}
elseif ($type == 'theme') {
$mask = "/$name\.info$/";
$extension = 'info';
}
else {
$mask = "/$name\.$type$/";
$extension = $type;
}
if (!function_exists('drupal_system_listing')) {
require_once DRUPAL_ROOT . '/includes/common.inc';
}
$matches = drupal_system_listing($mask, $dir, 'name', 0);
if (!empty($matches[$name]->uri)) {
$files[$type][$name] = $matches[$name]->uri;
// 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("/\.$extension$/", $dir, 'name', 0);
foreach ($matches as $matched_name => $file) {
$files[$type][$matched_name] = $file->uri;
}
}
}
......
......@@ -478,21 +478,6 @@ function drupal_rewrite_settings($settings = array(), $prefix = '') {
}
}
/**
* Get list of all .install files.
*
* @param $module_list
* An array of modules to search for their .install files.
*/
function drupal_get_install_files($module_list = array()) {
$installs = array();
foreach ($module_list as $module) {
$installs = array_merge($installs, drupal_system_listing('/' . $module . '.install$/', 'modules'));
}
return $installs;
}
/**
* Verify an install profile for installation.
*
......@@ -988,14 +973,11 @@ function drupal_check_profile($profile) {
$info = install_profile_info($profile);
// Get a list of all .install files.
$installs = drupal_get_install_files($info['dependencies']);
// Collect requirement testing results
// Collect requirement testing results.
$requirements = array();
foreach ($installs as $install) {
require_once DRUPAL_ROOT . '/' . $install->uri;
$function = $install->name . '_requirements';
foreach ($info['dependencies'] as $module) {
module_load_install($module);
$function = $module . '_requirements';
if (function_exists($function)) {
$requirements = array_merge($requirements, $function('install'));
}
......@@ -1031,11 +1013,8 @@ function drupal_requirements_severity(&$requirements) {
* TRUE/FALSE depending on the requirements are in place.
*/
function drupal_check_module($module) {
// Include install file
$install = drupal_get_install_files(array($module));
if (isset($install[$module])) {
require_once DRUPAL_ROOT . '/' . $install[$module]->uri;
module_load_install($module);
if (module_hook($module, 'requirements')) {
// Check requirements
$requirements = module_invoke($module, 'requirements', 'install');
if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment