protected function preload_contexts(array $contextids) {
        global $DB;

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

        $ctxfields = \context_helper::get_preload_record_columns_sql('ctx');
        list($insql, $inparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
        $sql = "SELECT {$ctxfields} FROM {context} ctx WHERE ctx.id {$insql}";
        $contextlist = $DB->get_recordset_sql($sql, $inparams);
        foreach ($contextlist as $contextdata) {
            \context_helper::preload_from_record($contextdata);
        }
        $contextlist->close();

    }