public static function get_customfields_data_contexts(string $component, string $area,
            string $itemidstest = 'IS NOT NULL', string $instanceidstest = 'IS NOT NULL', array $params = []) : contextlist {

        $sql = "SELECT d.contextid FROM {customfield_category} c
            JOIN {customfield_field} f ON f.categoryid = c.id
            JOIN {customfield_data} d ON d.fieldid = f.id AND d.instanceid $instanceidstest
            WHERE c.component = :cfcomponent AND c.area = :cfarea AND c.itemid $itemidstest";

        $contextlist = new contextlist();
        $contextlist->add_from_sql($sql, self::get_params($component, $area, $params));

        return $contextlist;
    }