original_string: public function delete() {
          global $DB;
  
          if ($this->_contextlevel <= CONTEXT_SYSTEM) {
              throw new coding_exception('Cannot delete system context');
          }
  
          // double check the context still exists
          if (!$DB->record_exists('context', array('id'=>$this->_id))) {
              context::cache_remove($this);
              return;
          }
  
          $this->delete_content();
          $DB->delete_records('context', array('id'=>$this->_id));
          // purge static context cache if entry present
          context::cache_remove($this);
      }
code: public function delete() {
          global $DB;
  
          if ($this->_contextlevel <= CONTEXT_SYSTEM) {
              throw new coding_exception('Cannot delete system context');
          }
  
          // double check the context still exists
          if (!$DB->record_exists('context', array('id'=>$this->_id))) {
              context::cache_remove($this);
              return;
          }
  
          $this->delete_content();
          $DB->delete_records('context', array('id'=>$this->_id));
          // purge static context cache if entry present
          context::cache_remove($this);
      }
code_tokens: public function delete ( ) { global $ DB ; if ( $ this -> _contextlevel <= CONTEXT_SYSTEM ) { throw new coding_exception ( 'Cannot delete system context' ) ; } // double check the context still exists if ( ! $ DB -> record_exists ( 'context' , array ( 'id' => $ this -> _id ) ) ) { context :: cache_remove ( $ this ) ; return ; } $ this -> delete_content ( ) ; $ DB -> delete_records ( 'context' , array ( 'id' => $ this -> _id ) ) ; // purge static context cache if entry present context :: cache_remove ( $ this ) ; }
docstring: Delete the context content and the context record itself
docstring_tokens: Delete the context content and the context record itself