Skipping thousands of require_once() calls because PHP5

is really slow (and heavy) with them. MDL-8700
This commit is contained in:
stronk7
2007-03-02 09:39:50 +00:00
parent 1ac2df9163
commit 01be5c29cc
+17 -1
View File
@@ -1736,6 +1736,16 @@
global $CFG,$preferences;
//Use one static variable to cache all the require_once calls that,
//under PHP5 seems to increase load too much, and we are requiring
//them here thousands of times (one per content). MDL-8700.
//Once fixed by PHP, we'll delete this hack
static $includedfiles;
if (!isset($includedfiles)) {
$includedfiles = array();
}
//Check if preferences is ok. If it isn't set, we are
//in a scheduled_backup to we are able to get a copy
//from CFG->backup_preferences
@@ -1755,8 +1765,14 @@
$result = str_replace($search,$replace,$content);
foreach ($mypreferences->mods as $name => $info) {
/// We only include the corresponding backuplib.php if it hasn't been included before
/// This will save some load under PHP5. MDL-8700.
/// Once fixed by PHP, we'll delete this hack
if (!in_array($name, $includedfiles)) {
include_once("$CFG->dirroot/mod/$name/backuplib.php");
$includedfiles[] = $name;
}
//Check if the xxxx_encode_content_links exists
include_once("$CFG->dirroot/mod/$name/backuplib.php");
$function_name = $name."_encode_content_links";
if (function_exists($function_name)) {
$result = $function_name($result,$mypreferences);