]> git.mjollnir.org Git - moodle.git/commitdiff
Skipping some thousands of require_once() calls because PHP5
authorstronk7 <stronk7>
Fri, 2 Mar 2007 09:42:52 +0000 (09:42 +0000)
committerstronk7 <stronk7>
Fri, 2 Mar 2007 09:42:52 +0000 (09:42 +0000)
is really slow (and heavy) with them. MDL-8700

Merged from MOODLE_18_STABLE

backup/backuplib.php

index 42da4b0811e558380816d78706ae2c774682dad9..e583a5d84eb9fd8b1aef5b7481ae35437222f1a9 100644 (file)
 
         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
         $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);