From f0d59102f528a9c66b1c3355bb6b2ee48f8b0282 Mon Sep 17 00:00:00 2001 From: David Rothstein Date: Mon, 1 Feb 2016 18:10:52 -0500 Subject: Issue #1443308 by cilefen, joseph.olstad, mikeytown2, joelpittet, btopro, alexpott, jonhattan, marcingy, stewsnooze, Fabianx, pounard, tstoeckler, penyaskito: Add static cache to module_load_include() --- includes/module.inc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'includes') 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; } -- cgit v1.2.3