public static function change_instances_context(array $taginstanceids, context $newcontext) {
        global $DB;

        if (empty($taginstanceids)) {
            return;
        }

        list($sql, $params) = $DB->get_in_or_equal($taginstanceids);
        $DB->set_field_select('tag_instance', 'contextid', $newcontext->id, "id {$sql}", $params);
    }