public static function get_users_in_context_from_sql(
                userlist $userlist, string $alias, string $component, string $area, int $contextid = null, string $insql = '',
                array $params = []) {

        if ($insql != '') {
            $insql = "AND {$alias}.itemid {$insql}";
        }
        $contextsql = '';
        if (isset($contextid)) {
            $contextsql = "AND {$alias}.contextid = :{$alias}contextid";
            $params["{$alias}contextid"] = $contextid;
        }

        // Comment authors.
        $sql = "SELECT {$alias}.userid
                  FROM {comments} {$alias}
                 WHERE {$alias}.component = :{$alias}component
                   AND {$alias}.commentarea = :{$alias}commentarea
                   $contextsql $insql";

        $params["{$alias}component"] = $component;
        $params["{$alias}commentarea"] = $area;

        $userlist->add_from_sql('userid', $sql, $params);
    }