]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10770, support null fields in backup/restore
authortoyomoyo <toyomoyo>
Fri, 10 Aug 2007 05:22:20 +0000 (05:22 +0000)
committertoyomoyo <toyomoyo>
Fri, 10 Aug 2007 05:22:20 +0000 (05:22 +0000)
backup/backuplib.php
backup/lib.php
backup/restorelib.php

index d70c6e51d0993ff53ecf626cb5716dd82cb82692..221d846939ee0c709c94b92530d832b5bfd03cba 100644 (file)
 
         global $CFG;
         //Here we encode absolute links
-        $content = backup_encode_absolute_links($content);
-
+        // MDL-10770
+        if (is_null($content)) {
+            $content = '_NULL_'; 
+        } else {
+            $content = backup_encode_absolute_links($content);
+        }
         $st = start_tag($tag,$level,$endline,$attributes);
 
         $co = xml_tag_safe_content($content);
index 72b562b656ad50e9f5421233e335d1c047b6f94a..52b087538194f4128dd33398503f7b7ceae26c1b 100644 (file)
     //This function is used to add slashes (and decode from UTF-8 if needed)
     //It's used intensivelly when restoring modules and saving them in db
     function backup_todb ($data) {
-        return restore_decode_absolute_links(addslashes($data));
+        // MDL-10770
+        if ($data === '_NULL_') {
+            return null; 
+        } else {
+            return restore_decode_absolute_links(addslashes($data));
+        }
     }
 
     //This function is used to check that every necessary function to
index 6ab234e08915a26062dc72471efc01d4611a4e2b..21bbcd2b04f788d86d5f66fb32f9ba7761d6aa50 100644 (file)
             $course->shortname = addslashes($course_header->course_shortname);
             $course->idnumber = addslashes($course_header->course_idnumber);
             $course->idnumber = ''; //addslashes($course_header->course_idnumber); // we don't want this at all.
-            $course->summary = restore_decode_absolute_links(addslashes($course_header->course_summary));
+            $course->summary = backup_todb($course_header->course_summary);
             $course->format = addslashes($course_header->course_format);
             $course->showgrades = addslashes($course_header->course_showgrades);
             $course->newsitems = addslashes($course_header->course_newsitems);
                 $sequence = "";
                 $section->course = $restore->course_id;
                 $section->section = $sect->number;
-                $section->summary = restore_decode_absolute_links(addslashes($sect->summary));
+                $section->summary = backup_todb($sect->summary);
                 $section->visible = $sect->visible;
                 $section->sequence = "";
                 //Now calculate the section's newid
                         }
                     }
                 }
-             }
+            }
         }
 
         // return if nothing to restore
                     $user->address = addslashes($user->address);
                     $user->city = addslashes($user->city);
                     $user->url = addslashes($user->url);
-                    $user->description = restore_decode_absolute_links(addslashes($user->description));
+                    $user->description = backup_todb($user->description);
 
                     //We need to analyse the AUTH field to recode it:
                     //   - if the field isn't set, we are in a pre 1.4 backup and we'll
 
         global $CFG,$restore;
 
+        // MDL-10770
+        // This function was replacing null with empty string
+        // Nullity check is added in backup_todb(), this function will no longer not be called from backup_todb() if content is null
+        // I noticed some parts of the restore code is calling this directly instead of calling backup_todb(), so just in case
+        // 3rd party mod etc are doing the same
+        if ($content === NULL) {
+            return NULL; 
+        }
+           
         //Now decode wwwroot and file.php calls
         $search = array ("$@FILEPHP@$");