MDL-65959 badge: Reset external_identifiers if backpack details modified
authorPeter Dias <peter@moodle.com>
Mon, 21 Sep 2020 06:28:28 +0000 (14:28 +0800)
committerPeter Dias <peter@moodle.com>
Mon, 26 Oct 2020 16:27:19 +0000 (00:27 +0800)
badges/backpacks.php

index 74beadd..635a164 100644 (file)
@@ -69,7 +69,11 @@ if ($action == 'edit') {
     } else if ($data = $form->get_data()) {
         require_sesskey();
         if (!empty($data->id)) {
     } else if ($data = $form->get_data()) {
         require_sesskey();
         if (!empty($data->id)) {
-            badges_update_site_backpack($data->id, $data);
+            $id = $data->id;
+            badges_update_site_backpack($id, $data);
+            // Apart from the password, any change here would result in an error in other parts of the badge systems.
+            // In order to negate this, we restart any further mapping from scratch.
+            badges_external_delete_mappings($id);
         } else {
             badges_create_site_backpack($data);
         }
         } else {
             badges_create_site_backpack($data);
         }