original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Gets a block instance with given id.
  
  Returns the fields id, pagetypepattern, subpagepattern from block_instances and also the
  cmid (if parent context is an activity module).
  
  @param int $id ID of block instance
  @param int $strictness MUST_EXIST or IGNORE_MISSING
  @return false|mixed Block instance data (may be false if strictness is IGNORE_MISSING)
docstring_tokens: Gets a block instance with given id .