summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2016-02-01 18:10:52 -0500
committerDavid Rothstein <drothstein@gmail.com>2016-02-01 18:10:52 -0500
commitf0d59102f528a9c66b1c3355bb6b2ee48f8b0282 (patch)
tree5c2f0a90964d7d2635e2266b75e13fd2fce4cb88
parent50c9b281548c18f09f03625a7bd41acc296a18c1 (diff)
downloadbrdo-f0d59102f528a9c66b1c3355bb6b2ee48f8b0282.tar.gz
brdo-f0d59102f528a9c66b1c3355bb6b2ee48f8b0282.tar.bz2
Issue #1443308 by cilefen, joseph.olstad, mikeytown2, joelpittet, btopro, alexpott, jonhattan, marcingy, stewsnooze, Fabianx, pounard, tstoeckler, penyaskito: Add static cache to module_load_include()
-rw-r--r--CHANGELOG.txt1
-rw-r--r--includes/module.inc11
2 files changed, 12 insertions, 0 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index a00ec9101..829cb8fd5 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,6 +1,7 @@
Drupal 7.42, xxxx-xx-xx (development version)
-----------------------
+- Added static caching to module_load_include() to improve performance.
- Fixed double-encoding bugs in select field widgets provided by the Options
module. The fix deprecates the 'strip_tags' property on option widgets and
replaces it with a new 'strip_tags_and_unescape' property (minor data
diff --git a/includes/module.inc b/includes/module.inc
index 7bf619b47..b92abcde9 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -320,16 +320,27 @@ function module_load_install($module) {
* The name of the included file, if successful; FALSE otherwise.
*/
function module_load_include($type, $module, $name = NULL) {
+ static $files = array();
+
if (!isset($name)) {
$name = $module;
}
+ $key = $type . ':' . $module . ':' . $name;
+ if (isset($files[$key])) {
+ return $files[$key];
+ }
+
if (function_exists('drupal_get_path')) {
$file = DRUPAL_ROOT . '/' . drupal_get_path('module', $module) . "/$name.$type";
if (is_file($file)) {
require_once $file;
+ $files[$key] = $file;
return $file;
}
+ else {
+ $files[$key] = FALSE;
+ }
}
return FALSE;
}