MDL-21432 backup - minor fix to xml transformer (32cc)
authorEloy Lafuente <stronk7@moodle.org>
Mon, 12 Jul 2010 22:45:52 +0000 (22:45 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Mon, 12 Jul 2010 22:45:52 +0000 (22:45 +0000)
backup/moodle2/backup_xml_transformer.class.php

index edd1010..f0be3cd 100644 (file)
@@ -68,8 +68,8 @@ class backup_xml_transformer extends xml_contenttransformer {
             return '';
         } else if (is_numeric($content)) {
             return $content;
-        } else if (strlen($content) < 36) { // Impossible to have one link in 36cc
-            return $content;                // (http://10.0.0.1/mod/url/view.php?id=)
+        } else if (strlen($content) < 32) { // Impossible to have one link in 32cc
+            return $content;                // (http://10.0.0.1/file.php/1/1.jpg, http://10.0.0.1/mod/url/view.php?id=)
         }
 
         $content = $this->process_filephp_links($content); // Replace all calls to file.php by $@FILEPHP@$ in a normalised way
@@ -81,6 +81,10 @@ class backup_xml_transformer extends xml_contenttransformer {
     private function process_filephp_links($content) {
         global $CFG;
 
+        if (strpos($content, 'file.php') === false) { // No file.php, nothing to convert
+            return $content;
+        }
+
         //First, we check for every call to file.php inside the course
         $search = array($CFG->wwwroot.'/file.php/' . $this->courseid,
                         $CFG->wwwroot.'/file.php?file=/' . $this->courseid,