diff --git a/backup/util/dbops/restore_dbops.class.php b/backup/util/dbops/restore_dbops.class.php index c4a60131e93..0d826fbba84 100644 --- a/backup/util/dbops/restore_dbops.class.php +++ b/backup/util/dbops/restore_dbops.class.php @@ -1215,6 +1215,9 @@ abstract class restore_dbops { $usertag = (object)$usertag; $tags[] = $usertag->rawname; } + if (empty($newuserctxid)) { + $newuserctxid = null; // Tag apis expect a null contextid not 0. + } tag_set('user', $newuserid, $tags, 'core', $newuserctxid); } diff --git a/tag/edit.php b/tag/edit.php index 3277cd75dac..b2b465501f2 100644 --- a/tag/edit.php +++ b/tag/edit.php @@ -136,7 +136,7 @@ if ($tagnew = $tagform->get_data()) { } //updated related tags - tag_set('tag', $tagnew->id, explode(',', trim($tagnew->relatedtags)), 'core', $systemcontext); + tag_set('tag', $tagnew->id, explode(',', trim($tagnew->relatedtags)), 'core', $systemcontext->id); //print_object($tagnew); die(); redirect($CFG->wwwroot.'/tag/index.php?tag='.rawurlencode($tag->name)); // must use $tag here, as the name isn't in the edit form