From 01bc98275a1c979b0bb4370c0019cf34b86a672f Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 2 Mar 2007 09:42:52 +0000 Subject: [PATCH] Skipping some thousands of require_once() calls because PHP5 is really slow (and heavy) with them. MDL-8700 Merged from MOODLE_18_STABLE --- backup/backuplib.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/backup/backuplib.php b/backup/backuplib.php index 42da4b0811..e583a5d84e 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -1843,6 +1843,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 @@ -1862,8 +1872,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); -- 2.39.5