]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11037 restore status ignored and reset in several places in restore code
authorskodak <skodak>
Tue, 28 Aug 2007 16:30:39 +0000 (16:30 +0000)
committerskodak <skodak>
Tue, 28 Aug 2007 16:30:39 +0000 (16:30 +0000)
backup/restorelib.php

index a82f89dd2592fea2932746ea0d2f5c2e90dc1b4d..fdd939830af6a5feb8976839b35fcb70c32fc296 100644 (file)
                             && !empty($restore->mods[$mod->modtype]->instances[$mod->id]->restore))) {
                         $modrestore = $mod->modtype."_restore_mods";
                         if (function_exists($modrestore)) {                                               //Debug
-                            $status = $status and $modrestore($mod,$restore); //bit operator & not reliable here!
+                             // we want to restore all mods even when one fails
+                             // incorrect code here ignored any errors during module restore in 1.6-1.8
+                            $status = $status && $modrestore($mod,$restore);
                         } else {
                             //Something was wrong. Function should exist.
                             $status = false;
         /*******************************************************************************
          ************* Restore of Roles and Capabilities happens here ******************
          *******************************************************************************/
-        $status = restore_create_roles($restore, $xml_file);
-        $status = restore_roles_settings($restore, $xml_file);
+         // try to restore roles even when restore is going to fail - teachers might have
+         // at least some role assigned - this is not correct though
+        $status = restore_create_roles($restore, $xml_file) && $status;
+        $status = restore_roles_settings($restore, $xml_file) && $status;
 
         //Now if all is OK, update:
         //   - course modinfo field
             }
         }
 
-        if ($status = restore_close_html($restore)){
+        // this is not a critical check - the result can be ignored
+        if (restore_close_html($restore)){
             if (!defined('RESTORE_SILENTLY')) {
                 echo '<li>Closing the Restorelog.html file.</li>';
             }
             if (!defined('RESTORE_SILENTLY')) {
                 notify("Could not close the restorelog.html file");
             }
-            else {
-                $errorstr = "Could not close the restorelog.html file";
-                return false;
-            }
         }
 
         if (!defined('RESTORE_SILENTLY')) {