protected function get_block_instance($id, $strictness = MUST_EXIST) {
        global $DB;

        $cache = \cache::make_from_params(\cache_store::MODE_REQUEST, 'core_search',
                self::CACHE_INSTANCES, [], ['simplekeys' => true]);
        $id = (int)$id;
        $instance = $cache->get($id);
        if (!$instance) {
            $instance = $DB->get_record_sql("
                    SELECT bi.id, bi.pagetypepattern, bi.subpagepattern,
                           c.id AS courseid, cm.id AS cmid
                      FROM {block_instances} bi
                      JOIN {context} parent ON parent.id = bi.parentcontextid
                 LEFT JOIN {course} c ON c.id = parent.instanceid AND parent.contextlevel = ?
                 LEFT JOIN {course_modules} cm ON cm.id = parent.instanceid AND parent.contextlevel = ?
                     WHERE bi.id = ?",
                    [CONTEXT_COURSE, CONTEXT_MODULE, $id], $strictness);
            $cache->set($id, $instance);
        }
        return $instance;
    }