<?php
/**
* @todo document
+ * @file
*/
/**
* @param Title $title
* @param int $id
* @return Revision
- * @access public
- * @static
*/
- public static function newFromTitle( &$title, $id = 0 ) {
+ public static function newFromTitle( $title, $id = 0 ) {
if( $id ) {
$matchId = intval( $id );
} else {
* @access public
* @static
*/
- public static function loadFromId( &$db, $id ) {
+ public static function loadFromId( $db, $id ) {
return Revision::loadFromConds( $db,
array( 'page_id=rev_page',
'rev_id' => intval( $id ) ) );
* @access public
* @static
*/
- public static function loadFromTitle( &$db, $title, $id = 0 ) {
+ public static function loadFromTitle( $db, $title, $id = 0 ) {
if( $id ) {
$matchId = intval( $id );
} else {
* @access public
* @static
*/
- public static function loadFromTimestamp( &$db, &$title, $timestamp ) {
+ public static function loadFromTimestamp( $db, $title, $timestamp ) {
return Revision::loadFromConds(
$db,
array( 'rev_timestamp' => $db->timestamp( $timestamp ),
* @access public
* @static
*/
- public static function fetchAllRevisions( &$title ) {
+ public static function fetchAllRevisions( $title ) {
return Revision::fetchFromConds(
wfGetDB( DB_SLAVE ),
array( 'page_namespace' => $title->getNamespace(),
* @access public
* @static
*/
- public static function fetchRevision( &$title ) {
+ public static function fetchRevision( $title ) {
return Revision::fetchFromConds(
wfGetDB( DB_SLAVE ),
array( 'rev_id=page_latest',
'rev_parent_id'
);
}
+
+ /**
+ * Return the list of text fields that should be selected to read the
+ * revision text
+ */
+ static function selectTextFields() {
+ return array(
+ 'old_text',
+ 'old_flags'
+ );
+ }
+ /**
+ * Return the list of page fields that should be selected from page table
+ */
+ static function selectPageFields() {
+ return array(
+ 'page_namespace',
+ 'page_title',
+ 'page_latest'
+ );
+ }
/**
* @param object $row
'Revision::getTitle' );
if( $row ) {
$this->mTitle = Title::makeTitle( $row->page_namespace,
- $row->page_title );
+ $row->page_title );
}
return $this->mTitle;
}
* @return Revision
*/
public function getPrevious() {
- $prev = $this->mTitle->getPreviousRevisionID( $this->mId );
- if( $prev ) {
- return Revision::newFromTitle( $this->mTitle, $prev );
- } else {
- return null;
+ if( $this->getTitle() ) {
+ $prev = $this->getTitle()->getPreviousRevisionID( $this->getId() );
+ if( $prev ) {
+ return Revision::newFromTitle( $this->getTitle(), $prev );
+ }
}
+ return null;
}
/**
* @return Revision
*/
public function getNext() {
- $next = $this->mTitle->getNextRevisionID( $this->mId );
- if ( $next ) {
- return Revision::newFromTitle( $this->mTitle, $next );
- } else {
- return null;
+ if( $this->getTitle() ) {
+ $next = $this->getTitle()->getNextRevisionID( $this->getId() );
+ if ( $next ) {
+ return Revision::newFromTitle( $this->getTitle(), $next );
+ }
}
+ return null;
}
/**
* @param Database $dbw
* @return int
*/
- public function insertOn( &$dbw ) {
+ public function insertOn( $dbw ) {
global $wgDefaultExternalStore;
wfProfileIn( __METHOD__ );
);
$this->mId = !is_null($rev_id) ? $rev_id : $dbw->insertId();
+
+ wfRunHooks( 'RevisionInsertComplete', array( &$this, $data, $flags ) );
+
wfProfileOut( __METHOD__ );
return $this->mId;
}
$text = self::getRevisionText( $row );
- if( $wgRevisionCacheExpiry ) {
+ # No negative caching -- negative hits on text rows may be due to corrupted slave servers
+ if( $wgRevisionCacheExpiry && $text !== false ) {
$wgMemc->set( $key, $text, $wgRevisionCacheExpiry );
}
* @param bool $minor
* @return Revision
*/
- public static function newNullRevision( &$dbw, $pageId, $summary, $minor ) {
+ public static function newNullRevision( $dbw, $pageId, $summary, $minor ) {
wfProfileIn( __METHOD__ );
$current = $dbw->selectRow(
if( ( $this->mDeleted & $field ) == $field ) {
global $wgUser;
$permission = ( $this->mDeleted & self::DELETED_RESTRICTED ) == self::DELETED_RESTRICTED
- ? 'hiderevision'
+ ? 'suppressrevision'
: 'deleterevision';
wfDebug( "Checking for $permission due to $field match on $this->mDeleted\n" );
return $wgUser->isAllowed( $permission );
/**
* Get rev_timestamp from rev_id, without loading the rest of the row
* @param integer $id
+ * @param integer $pageid, optional
*/
- static function getTimestampFromID( $id ) {
+ static function getTimestampFromId( $id, $pageId = 0 ) {
$dbr = wfGetDB( DB_SLAVE );
- $timestamp = $dbr->selectField( 'revision', 'rev_timestamp',
- array( 'rev_id' => $id ), __METHOD__ );
+ $conds = array( 'rev_id' => $id );
+ if( $pageId ) {
+ $conds['rev_page'] = $pageId;
+ }
+ $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
if ( $timestamp === false ) {
# Not in slave, try master
$dbw = wfGetDB( DB_MASTER );
- $timestamp = $dbw->selectField( 'revision', 'rev_timestamp',
- array( 'rev_id' => $id ), __METHOD__ );
+ $timestamp = $dbw->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
}
- return $timestamp;
+ return wfTimestamp( TS_MW, $timestamp );
}
/**