original_string: public static function instance($blockinstanceid, $strictness = MUST_EXIST) {
          global $DB;
  
          if ($context = context::cache_get(CONTEXT_BLOCK, $blockinstanceid)) {
              return $context;
          }
  
          if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $blockinstanceid))) {
              if ($bi = $DB->get_record('block_instances', array('id' => $blockinstanceid), 'id,parentcontextid', $strictness)) {
                  $parentcontext = context::instance_by_id($bi->parentcontextid);
                  $record = context::insert_context_record(CONTEXT_BLOCK, $bi->id, $parentcontext->path);
              }
          }
  
          if ($record) {
              $context = new context_block($record);
              context::cache_add($context);
              return $context;
          }
  
          return false;
      }
code: public static function instance($blockinstanceid, $strictness = MUST_EXIST) {
          global $DB;
  
          if ($context = context::cache_get(CONTEXT_BLOCK, $blockinstanceid)) {
              return $context;
          }
  
          if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $blockinstanceid))) {
              if ($bi = $DB->get_record('block_instances', array('id' => $blockinstanceid), 'id,parentcontextid', $strictness)) {
                  $parentcontext = context::instance_by_id($bi->parentcontextid);
                  $record = context::insert_context_record(CONTEXT_BLOCK, $bi->id, $parentcontext->path);
              }
          }
  
          if ($record) {
              $context = new context_block($record);
              context::cache_add($context);
              return $context;
          }
  
          return false;
      }
code_tokens: public static function instance ( $ blockinstanceid , $ strictness = MUST_EXIST ) { global $ DB ; if ( $ context = context :: cache_get ( CONTEXT_BLOCK , $ blockinstanceid ) ) { return $ context ; } if ( ! $ record = $ DB -> get_record ( 'context' , array ( 'contextlevel' => CONTEXT_BLOCK , 'instanceid' => $ blockinstanceid ) ) ) { if ( $ bi = $ DB -> get_record ( 'block_instances' , array ( 'id' => $ blockinstanceid ) , 'id,parentcontextid' , $ strictness ) ) { $ parentcontext = context :: instance_by_id ( $ bi -> parentcontextid ) ; $ record = context :: insert_context_record ( CONTEXT_BLOCK , $ bi -> id , $ parentcontext -> path ) ; } } if ( $ record ) { $ context = new context_block ( $ record ) ; context :: cache_add ( $ context ) ; return $ context ; } return false ; }
docstring: Returns block context instance.
  
  @static
  @param int $blockinstanceid id from {block_instances} table.
  @param int $strictness
  @return context_block context instance
docstring_tokens: Returns block context instance .