Fix Special:Export for new schema.
/**
* Need the CacheManager to be loaded
*/
-require_once ( 'CacheManager.php' );
+require_once( 'CacheManager.php' );
+require_once( 'Revision.php' );
$wgArticleCurContentFields = false;
$wgArticleOldContentFields = false;
$this->mForUpdate = false;
}
- /**
- * Get revision text associated with an old or archive row
- * $row is usually an object from wfFetchRow(), both the flags and the text
- * field must be included
- * @static
- * @param integer $row Id of a row
- * @param string $prefix table prefix (default 'old_')
- * @return string $text|false the text requested
- */
- function getRevisionText( $row, $prefix = 'old_' ) {
- $fname = 'Article::getRevisionText';
- wfProfileIn( $fname );
-
- # Get data
- $textField = $prefix . 'text';
- $flagsField = $prefix . 'flags';
-
- if( isset( $row->$flagsField ) ) {
- $flags = explode( ',', $row->$flagsField );
- } else {
- $flags = array();
- }
-
- if( isset( $row->$textField ) ) {
- $text = $row->$textField;
- } else {
- wfProfileOut( $fname );
- return false;
- }
-
- if( in_array( 'gzip', $flags ) ) {
- # Deal with optional compression of archived pages.
- # This can be done periodically via maintenance/compressOld.php, and
- # as pages are saved if $wgCompressRevisions is set.
- $text = gzinflate( $text );
- }
-
- if( in_array( 'object', $flags ) ) {
- # Generic compressed storage
- $obj = unserialize( $text );
-
- # Bugger, corrupted my test database by double-serializing
- if ( !is_object( $obj ) ) {
- $obj = unserialize( $obj );
- }
-
- $text = $obj->getText();
- }
-
- global $wgLegacyEncoding;
- if( $wgLegacyEncoding && !in_array( 'utf-8', $flags ) ) {
- # Old revisions kept around in a legacy encoding?
- # Upconvert on demand.
- global $wgInputEncoding, $wgContLang;
- $text = $wgContLang->iconv( $wgLegacyEncoding, $wgInputEncoding, $text );
- }
- wfProfileOut( $fname );
- return $text;
- }
-
- /**
- * If $wgCompressRevisions is enabled, we will compress data.
- * The input string is modified in place.
- * Return value is the flags field: contains 'gzip' if the
- * data is compressed, and 'utf-8' if we're saving in UTF-8
- * mode.
- *
- * @static
- * @param mixed $text reference to a text
- * @return string
- */
- function compressRevisionText( &$text ) {
- global $wgCompressRevisions, $wgUseLatin1;
- $flags = array();
- if( !$wgUseLatin1 ) {
- # Revisions not marked this way will be converted
- # on load if $wgLegacyCharset is set in the future.
- $flags[] = 'utf-8';
- }
- if( $wgCompressRevisions ) {
- if( function_exists( 'gzdeflate' ) ) {
- $text = gzdeflate( $text );
- $flags[] = 'gzip';
- } else {
- wfDebug( "Article::compressRevisionText() -- no zlib support, not compressing\n" );
- }
- }
- return implode( ',', $flags );
- }
-
/**
* Note that getContent/loadContent may follow redirects if
* not told otherwise, and so may cause a change to mTitle.
# If we got a redirect, follow it (unless we've been told
# not to by either the function parameter or the query
if ( !$oldid && !$noredir ) {
- $rt = Title::newFromRedirect( Article::getRevisionText( $s ) );
+ $rt = Title::newFromRedirect( Revision::getRevisionText( $s ) );
# process if title object is valid and not special:userlogout
if ( $rt && ! ( $rt->getNamespace() == NS_SPECIAL && $rt->getText() == 'Userlogout' ) ) {
# Gotta hand redirects to special pages differently:
$this->mTitle->mRestrictionsLoaded = true;
$this->mTouched = wfTimestamp( TS_MW, $s->page_touched );
- $this->mContent = Article::getRevisionText( $s );
+ $this->mContent = Revision::getRevisionText( $s );
$this->mUser = $s->rev_user;
$this->mUserText = $s->rev_user_text;
$isminor = ( $isminor && $wgUser->getID() ) ? 1 : 0;
$mungedText = $text;
- $flags = Article::compressRevisionText( $mungedText );
+ $flags = Revision::compressRevisionText( $mungedText );
$dbw =& wfGetDB( DB_MASTER );
$fname );
$obj = $dbw->fetchObject( $result );
$dbw->freeResult( $result );
- $oldtext = Article::getRevisionText( $obj );
+ $oldtext = Revision::getRevisionText( $obj );
return $oldtext;
}
$won = wfInvertTimestamp( $now );
$mungedText = $text;
- $flags = Article::compressRevisionText( $newtext );
+ $flags = Revision::compressRevisionText( $newtext );
$lastRevision = $dbw->selectField(
'page', 'page_latest', array( 'page_id' => $this->getId() ) );
$text=$s->cur_text;
} else {
if($old) {
- $text = Article::getRevisionText( $old );
+ $text = Revision::getRevisionText( $old );
$blanked = true;
}
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$wgOut->addHTML( '<h2>' . htmlspecialchars( $newcomment ) . "</h2>\n<hr />\n" );
- $this->updateArticle( Article::getRevisionText( $s ), $newcomment, 1, $this->mTitle->userIsWatching(), $bot );
+ $this->updateArticle( Revision::getRevisionText( $s ), $newcomment, 1, $this->mTitle->userIsWatching(), $bot );
Article::onArticleEdit( $this->mTitle );
$wgOut->returnToMain( false );
}
* @subpackage DifferenceEngine
*/
+require_once( 'Revision.php' );
+
/**
* @todo document
* @access public
$fname = 'DifferenceEngine::loadText';
$dbr =& wfGetDB( DB_SLAVE );
- if ( 0 == $this->mNewid || 0 == $this->mOldid ) {
- /* Fetch current revision */
- $wgOut->setArticleFlag( true );
- $newLink = $wgTitle->escapeLocalUrl();
+ if( $this->mNewid ) {
+ $this->newRev =& Revision::newFromId( $this->mNewid );
+ } else {
+ $this->newRev =& Revision::newFromTitle( $wgTitle );
+ }
+
+ if( $this->newRev->isCurrent() ) {
$this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev' ) );
+ $this->mNewPage = $wgTitle;
+ $newLink = $this->mNewPage->escapeLocalUrl();
$this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>";
- $id = $wgTitle->getArticleID();
-
- $s = $dbr->selectRow( array( 'page', 'revision', 'text' ),
- array( 'old_flags', 'old_text', 'rev_user_text', 'rev_comment' ),
- "page_id=$id AND page_id=rev_page AND rev_id=old_id", $fname );
- if ( $s === false ) {
- wfDebug( "Unable to load page_id $id\n" );
- return false;
- }
-
- $this->mNewPage = &$wgTitle;
- $this->mNewtext = Article::getRevisionText( $s );
- $this->mNewUser = $s->rev_user_text;
- $this->mNewComment = $s->rev_comment;
} else {
- $s = $dbr->selectRow( array( 'page', 'revision', 'text' ),
- array( 'page_namespace','page_title','rev_timestamp', 'old_text',
- 'old_flags','rev_user_text','rev_comment' ),
- "page_id=rev_page AND rev_id=old_id AND rev_id={$this->mNewid}",
- $fname );
-
- if ( $s === false ) {
- wfDebug( "Unable to load old_id {$this->mNewid}\n" );
- return false;
- }
-
- $this->mNewtext = Article::getRevisionText( $s );
-
- $t = $wgLang->timeanddate( $s->rev_timestamp, true );
- $this->mNewPage = Title::MakeTitle( $s->page_namespace, $s->page_title );
- $newLink = $wgTitle->escapeLocalUrl ('oldid=' . $this->mNewid);
+ $this->mNewPage = $this->newRev->getTitle();
+ $newLink = $this->mNewPage->escapeLocalUrl ('oldid=' . $this->mNewid );
+ $t = $wgLang->timeanddate( $this->newRev->getTimestamp(), true );
$this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $t ) );
$this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>";
- $this->mNewUser = $s->rev_user_text;
- $this->mNewComment = $s->rev_comment;
}
- if ( 0 == $this->mOldid ) {
- $s = $dbr->selectRow( 'old',
- array( 'old_namespace','old_title','old_timestamp','old_text', 'old_flags','old_user_text','old_comment' ),
- array( /* WHERE */
- 'old_namespace' => $this->mNewPage->getNamespace(),
- 'old_title' => $this->mNewPage->getDBkey()
- ), $fname, array( 'ORDER BY' => 'inverse_timestamp', 'USE INDEX' => 'name_title_timestamp' )
- );
- if ( $s === false ) {
- wfDebug( 'Unable to load ' . $this->mNewPage->getPrefixedDBkey() . " from old\n" );
- return false;
- }
+
+ if( $this->mOldid ) {
+ $this->oldRev =& Revision::newFromId( $this->mOldid );
} else {
- $s = $dbr->selectRow( array( 'page', 'revision', 'text' ),
- array( 'page_namespace','page_title','rev_timestamp','old_text','old_flags','rev_user_text','rev_comment'),
- "page_id=rev_page AND rev_id=old_id AND rev_id={$this->mOldid}",
- $fname
- );
- if ( $s === false ) {
- wfDebug( "Unable to load old_id {$this->mOldid}\n" );
- return false;
- }
+ $this->oldRev =& $this->newRev->getPrevious();
}
- $this->mOldPage = Title::MakeTitle( $s->page_namespace, $s->page_title );
- $this->mOldtext = Article::getRevisionText( $s );
+
+ $this->mOldPage = $this->oldRev->getTitle();
- $t = $wgLang->timeanddate( $s->rev_timestamp, true );
- $oldLink = $this->mOldPage->escapeLocalUrl ('oldid=' . $this->mOldid);
+ $t = $wgLang->timeanddate( $this->oldRev->getTimestamp(), true );
+ $oldLink = $this->mOldPage->escapeLocalUrl( 'oldid=' . $this->mOldid );
$this->mOldtitle = "<a href='$oldLink'>" . htmlspecialchars( wfMsg( 'revisionasof', $t ) ) . '</a>';
- $this->mOldUser = $s->rev_user_text;
- $this->mOldComment = $s->rev_comment;
+
+ $this->mNewUser = $this->newRev->getUserText();
+ $this->mNewComment = $this->newRev->getComment();
+ $this->mNewtext = $this->newRev->getText();
+
+ $this->mOldUser = $this->oldRev->getUserText();
+ $this->mOldComment = $this->oldRev->getComment();
+ $this->mOldtext = $this->oldRev->getText();
return true;
}
# be other revisions in the same object
function setText() {}
- # Get default text. This is called from Article::getRevisionText()
+ # Get default text. This is called from Revision::getRevisionText()
function getText() {}
}
* @package MediaWiki
*/
+require_once( 'Revision.php' );
+
/**
*
*/
$this->mCache = array();
for ( $row = $dbr->fetchObject( $res ); $row; $row = $dbr->fetchObject( $res ) ) {
- $this->mCache[$row->page_title] = Article::getRevisionText( $row );
+ $this->mCache[$row->page_title] = Revision::getRevisionText( $row );
}
$dbr->freeResult( $res );
' AND page_latest=old_id',
'MessageCache::get' );
if ( $result ) {
- $message = Article::getRevisionText( $result );
+ $message = Revision::getRevisionText( $result );
if ($this->mUseCache) {
$this->mCache[$title]=$message;
/* individual messages may be often
* @package MediaWiki
*/
+require_once( 'Revision.php' );
+
/**
* @todo document
* @package MediaWiki
$fname = 'RawPage::getrawtext';
if( !$this->mTitle ) return '';
- $dbr =& wfGetDB( DB_SLAVE );
- extract( $dbr->tableNames( 'revision', 'page', 'text' ) );
-
- $t = $dbr->strencode( $this->mTitle->getDBKey() );
- $ns = $this->mTitle->getNamespace();
- # special case
- if($ns == NS_MEDIAWIKI) {
- $rawtext = wfMsg($t);
+
+ # Special case for MediaWiki: messages; we can hit the message cache.
+ if( $this->mTitle->getNamespace() == NS_MEDIAWIKI) {
+ $rawtext = wfMsg( $this->mTitle->getDbkey() );
return $rawtext;
}
+
# else get it from the DB
- $sql = "SELECT old_text AS text, rev_timestamp AS timestamp
- FROM $text, $revision";
- if(!empty($this->mOldId)) {
- $sql .= " WHERE old_id={$this->mOldId} AND rev_id={$this->mOldId}";
- } else {
- $sql .= ", $page
- WHERE page_namespace=$ns AND page_title='$t'
- AND page_latest=rev_id AND rev_id=old_id";
- }
- $res = $dbr->query( $sql, $fname );
- if( $s = $dbr->fetchObject( $res ) ) {
- $rawtext = Article::getRevisionText( $s, "" );
- header( 'Last-modified: '.gmdate( "D, j M Y H:i:s", wfTimestamp( TS_UNIX, $s->timestamp )).' GMT' );
- return $rawtext;
+ $rev = Revision::newFromTitle( $this->mTitle, $this->mOldId );
+ if( $rev ) {
+ $lastmod = wfTimestamp( TS_RFC2822, $rev->getTimestamp() );
+ header( 'Last-modified: ' . $lastmod );
+ return $rev->getText();
} else {
return '';
}
--- /dev/null
+<?php
+
+require_once( 'Database.php' );
+require_once( 'Article.php' );
+
+class Revision {
+ /**
+ * Load a page revision from a given revision ID number.
+ * Returns null if no such revision can be found.
+ *
+ * @param int $id
+ * @static
+ * @access public
+ */
+ function &newFromId( $id ) {
+ return Revision::newFromConds(
+ array( 'page_id=rev_page',
+ 'rev_id' => IntVal( $id ),
+ 'rev_id=old_id' ) );
+ }
+
+ /**
+ * Load either the current, or a specified, revision
+ * that's attached to a given title. If not attached
+ * to that title, will return null.
+ *
+ * @param Title $title
+ * @param int $id
+ * @return Revision
+ * @access public
+ */
+ function &newFromTitle( &$title, $id = 0 ) {
+ if( $id ) {
+ $matchId = IntVal( $id );
+ } else {
+ $matchId = 'page_latest';
+ }
+ return Revision::newFromConds(
+ array( "rev_id=$matchId",
+ 'page_id=rev_page',
+ 'page_namespace' => $title->getNamespace(),
+ 'page_title' => $title->getDbkey(),
+ 'rev_id=old_id' ) );
+ }
+
+ /**
+ * Given a set of conditions, fetch a revision.
+ *
+ * @param array $conditions
+ * @return Revision
+ * @static
+ * @access private
+ */
+ function &newFromConds( $conditions ) {
+ $res =& Revision::fetchFromConds( $conditions );
+ if( $res ) {
+ $row = $res->fetchObject();
+ $res->free();
+ if( $row ) {
+ return new Revision( $row );
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return a wrapper for a series of database rows to
+ * fetch all of a given page's revisions in turn.
+ * Each row can be fed to the constructor to get objects.
+ *
+ * @param Title $title
+ * @return ResultWrapper
+ * @static
+ * @access public
+ */
+ function &fetchAllRevisions( &$title ) {
+ return Revision::fetchFromConds(
+ array( 'page_namespace' => $title->getNamespace(),
+ 'page_title' => $title->getDbkey(),
+ 'page_id=rev_page',
+ 'rev_id=old_id' ) );
+ }
+
+ /**
+ * Return a wrapper for a series of database rows to
+ * fetch all of a given page's revisions in turn.
+ * Each row can be fed to the constructor to get objects.
+ *
+ * @param Title $title
+ * @return ResultWrapper
+ * @static
+ * @access public
+ */
+ function &fetchRevision( &$title ) {
+ return Revision::fetchFromConds(
+ array( 'rev_id=page_latest',
+ 'page_namespace' => $title->getNamespace(),
+ 'page_title' => $title->getDbkey(),
+ 'page_id=rev_page',
+ 'rev_id=old_id' ) );
+ }
+ /**
+ * Given a set of conditions, return a ResultWrapper
+ * which will return matching database rows with the
+ * fields necessary to build Revision objects.
+ *
+ * @param array $conditions
+ * @return ResultWrapper
+ * @static
+ * @access private
+ */
+ function &fetchFromConds( $conditions ) {
+ $dbr =& wfGetDB( DB_SLAVE );
+ $res = $dbr->select(
+ array( 'page', 'revision', 'text' ),
+ array( 'page_namespace',
+ 'page_title',
+ 'page_latest',
+ 'rev_id',
+ 'rev_page',
+ 'rev_comment',
+ 'rev_user_text',
+ 'rev_user',
+ 'rev_minor_edit',
+ 'rev_timestamp',
+ 'old_flags',
+ 'old_text' ),
+ $conditions,
+ 'Revision::fetchRow' );
+ return $dbr->resultObject( $res );
+ }
+
+ /**
+ * @param object $row
+ * @access private
+ */
+ function Revision( $row ) {
+ $this->mId = IntVal( $row->rev_id );
+ $this->mPage = IntVal( $row->rev_page );
+ $this->mComment = $row->rev_comment;
+ $this->mUserText = $row->rev_user_text;
+ $this->mUser = IntVal( $row->rev_user );
+ $this->mMinorEdit = IntVal( $row->rev_minor_edit );
+ $this->mTimestamp = $row->rev_timestamp;
+
+ $this->mCurrent = ( $row->rev_id == $row->page_latest );
+ $this->mTitle = Title::makeTitle( $row->page_namespace,
+ $row->page_title );
+ $this->mText = $this->getRevisionText( $row );
+ }
+
+ /** @+
+ * @access public
+ */
+
+ /**
+ * @return int
+ */
+ function getId() {
+ return $this->mId;
+ }
+
+ /**
+ * Returns the title of the page associated with this entry.
+ * @return Title
+ */
+ function &getTitle() {
+ if( isset( $this->mTitle ) ) {
+ return $this->mTitle;
+ }
+ $dbr =& wfGetDB( DB_SLAVE );
+ $row = $dbr->selectRow(
+ array( 'page', 'revision' ),
+ array( 'page_namespace', 'page_title' ),
+ array( 'page_id=rev_page',
+ 'rev_id' => $this->mId ),
+ 'Revision::getTItle' );
+ if( $row ) {
+ $this->mTitle =& Title::makeTitle( $row->page_namespace,
+ $row->page_title );
+ }
+ return $this->mTitle;
+ }
+
+ /**
+ * @return int
+ */
+ function getUser() {
+ return $this->mUser;
+ }
+
+ /**
+ * @return string
+ */
+ function getUserText() {
+ return $this->mUserText;
+ }
+
+ /**
+ * @return string
+ */
+ function getComment() {
+ return $this->mComment;
+ }
+
+ /**
+ * @return bool
+ */
+ function isMinor() {
+ return (bool)$this->mMinorEdit;
+ }
+
+ /**
+ * @return string
+ */
+ function getText() {
+ return $this->mText;
+ }
+
+ /**
+ * @return string
+ */
+ function getTimestamp() {
+ return $this->mTimestamp;
+ }
+
+ /**
+ * @return bool
+ */
+ function isCurrent() {
+ return $this->mCurrent;
+ }
+
+ /**
+ * @return Revision
+ */
+ function &getPrevious() {
+ $prev = $this->mTitle->getPreviousRevisionID( $this->mId );
+ return Revision::newFromTitle( $this->mTitle, $prev );
+ }
+
+ /**
+ * @return Revision
+ */
+ function &getNext() {
+ $next = $this->mTitle->getNextRevisionID( $this->mId );
+ return Revision::newFromTitle( $this->mTitle, $next );
+ }
+ /** @- */
+
+ /**
+ * Get revision text associated with an old or archive row
+ * $row is usually an object from wfFetchRow(), both the flags and the text
+ * field must be included
+ * @static
+ * @param integer $row Id of a row
+ * @param string $prefix table prefix (default 'old_')
+ * @return string $text|false the text requested
+ */
+ function getRevisionText( $row, $prefix = 'old_' ) {
+ $fname = 'Revision::getRevisionText';
+ wfProfileIn( $fname );
+
+ # Get data
+ $textField = $prefix . 'text';
+ $flagsField = $prefix . 'flags';
+
+ if( isset( $row->$flagsField ) ) {
+ $flags = explode( ',', $row->$flagsField );
+ } else {
+ $flags = array();
+ }
+
+ if( isset( $row->$textField ) ) {
+ $text = $row->$textField;
+ } else {
+ wfProfileOut( $fname );
+ return false;
+ }
+
+ if( in_array( 'gzip', $flags ) ) {
+ # Deal with optional compression of archived pages.
+ # This can be done periodically via maintenance/compressOld.php, and
+ # as pages are saved if $wgCompressRevisions is set.
+ $text = gzinflate( $text );
+ }
+
+ if( in_array( 'object', $flags ) ) {
+ # Generic compressed storage
+ $obj = unserialize( $text );
+
+ # Bugger, corrupted my test database by double-serializing
+ if ( !is_object( $obj ) ) {
+ $obj = unserialize( $obj );
+ }
+
+ $text = $obj->getText();
+ }
+
+ global $wgLegacyEncoding;
+ if( $wgLegacyEncoding && !in_array( 'utf-8', $flags ) ) {
+ # Old revisions kept around in a legacy encoding?
+ # Upconvert on demand.
+ global $wgInputEncoding, $wgContLang;
+ $text = $wgContLang->iconv( $wgLegacyEncoding, $wgInputEncoding, $text );
+ }
+ wfProfileOut( $fname );
+ return $text;
+ }
+
+ /**
+ * If $wgCompressRevisions is enabled, we will compress data.
+ * The input string is modified in place.
+ * Return value is the flags field: contains 'gzip' if the
+ * data is compressed, and 'utf-8' if we're saving in UTF-8
+ * mode.
+ *
+ * @static
+ * @param mixed $text reference to a text
+ * @return string
+ */
+ function compressRevisionText( &$text ) {
+ global $wgCompressRevisions, $wgUseLatin1;
+ $flags = array();
+ if( !$wgUseLatin1 ) {
+ # Revisions not marked this way will be converted
+ # on load if $wgLegacyCharset is set in the future.
+ $flags[] = 'utf-8';
+ }
+ if( $wgCompressRevisions ) {
+ if( function_exists( 'gzdeflate' ) ) {
+ $text = gzdeflate( $text );
+ $flags[] = 'gzip';
+ } else {
+ wfDebug( "Revision::compressRevisionText() -- no zlib support, not compressing\n" );
+ }
+ }
+ return implode( ',', $flags );
+ }
+
+
+}
+
+
+?>
\ No newline at end of file
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# http://www.gnu.org/copyleft/gpl.html
+require_once( 'Revision.php' );
+
/**
*
* @package MediaWiki
}
$dbr =& wfGetDB( DB_SLAVE );
- $s = $dbr->selectRow( 'cur', array( 'cur_id as id','cur_timestamp as timestamp','cur_user as user',
- 'cur_user_text as user_text', 'cur_restrictions as restrictions','cur_comment as comment',
- 'cur_text as text' ), $title->curCond(), $fname );
- if( $s !== false ) {
+ $s = $dbr->selectRow( 'page',
+ array( 'page_id', 'page_restrictions' ),
+ array( 'page_namespace' => $title->getNamespace(),
+ 'page_title' => $title->getDbkey() ) );
+ if( $s ) {
$tl = xmlsafe( $title->getPrefixedText() );
$xml = " <page>\n";
$xml .= " <title>$tl</title>\n";
+
if( $full ) {
- $xml .= " <id>$s->id</id>\n";
+ $xml .= " <id>$s->page_id</id>\n";
}
- if( $s->restrictions ) {
- $xml .= " <restrictions>$s->restrictions</restrictions>\n";
+ if( $s->page_restrictions ) {
+ $xml .= " <restrictions>" . xmlsafe( $s->page_restrictions ) . "</restrictions>\n";
}
- if( !$curonly ) {
- $res = $dbr->select( 'old', array( 'old_id as id','old_timestamp as timestamp',
- 'old_user as user', 'old_user_text as user_text', 'old_comment as comment',
- 'old_text as text', 'old_flags as flags' ), $title->oldCond(),
- $fname, array( 'ORDER BY' => 'old_timestamp' )
- );
- while( $s2 = $dbr->fetchObject( $res ) ) {
- $xml .= revision2xml( $s2, $full, false );
+ if( $curonly ) {
+ $res = Revision::fetchRevision( $title );
+ } else {
+ $res = Revision::fetchAllRevisions( $title );
+ }
+ if( $res ) {
+ while( $s = $res->fetchObject() ) {
+ $rev = new Revision( $s );
+ $xml .= revision2xml( $rev, $full, false );
}
+ $res->free();
}
- $xml .= revision2xml( $s, $full, true );
+
$xml .= " </page>\n";
wfProfileOut( $fname );
return $xml;
}
}
-function revision2xml( $s, $full, $cur ) {
+/**
+ * @return string
+ * @param Revision $rev
+ * @param bool $full
+ * @access private
+ */
+function revision2xml( $rev, $full ) {
$fname = 'revision2xml';
wfProfileIn( $fname );
- $ts = wfTimestamp2ISO8601( $s->timestamp );
$xml = " <revision>\n";
- if($full && !$cur)
- $xml .= " <id>$s->id</id>\n";
+ if( $full )
+ $xml .= " <id>" . $rev->getId() . "</id>\n";
+
+ $ts = wfTimestamp2ISO8601( $rev->getTimestamp() );
$xml .= " <timestamp>$ts</timestamp>\n";
- if($s->user) {
- $u = "<username>" . xmlsafe( $s->user_text ) . "</username>";
- if($full)
- $u .= "<id>$s->user</id>";
+
+ if( $rev->getUser() ) {
+ $u = "<username>" . xmlsafe( $rev->getUserText() ) . "</username>";
+ if( $full )
+ $u .= "<id>" . $rev->getUser() . "</id>";
} else {
- $u = "<ip>" . xmlsafe( $s->user_text ) . "</ip>";
+ $u = "<ip>" . xmlsafe( $rev->getUserText() ) . "</ip>";
}
$xml .= " <contributor>$u</contributor>\n";
- if( !empty( $s->minor ) ) {
+
+ if( $rev->isMinor() ) {
$xml .= " <minor/>\n";
}
- if($s->comment != "") {
- $c = xmlsafe( $s->comment );
+ if($rev->getComment() != "") {
+ $c = xmlsafe( $rev->getComment() );
$xml .= " <comment>$c</comment>\n";
}
- $t = xmlsafe( Article::getRevisionText( $s, "" ) );
+ $t = xmlsafe( $rev->getText() );
$xml .= " <text>$t</text>\n";
$xml .= " </revision>\n";
wfProfileOut( $fname );
*/
require_once( 'Feed.php' );
require_once( 'ChangesList.php' );
+require_once( 'Revision.php' );
/**
* Constructor
#$diff =& new DifferenceEngine( $row->rc_this_oldid, $row->rc_last_oldid, $row->rc_id );
#$diff->showDiffPage();
+ $titleObj = Title::makeTitle( $row->rc_namespace, $row->rc_title );
$dbr =& wfGetDB( DB_SLAVE );
- if( $row->rc_this_oldid ) {
- $newrow = $dbr->selectRow( 'old',
- array( 'old_flags', 'old_text' ),
- array( 'old_id' => $row->rc_this_oldid ) );
- $newtext = Article::getRevisionText( $newrow );
+ $newrev =& Revision::newFromTitle( $titleObj, $row->rc_this_oldid );
+ if( $newrev ) {
+ $newtext = $newrev->getText();
} else {
- $newrow = $dbr->selectRow( 'cur',
- array( 'cur_text' ),
- array( 'cur_id' => $row->rc_cur_id ) );
- $newtext = $newrow->cur_text;
+ $diffText = "<p>Can't load revision $row->rc_this_oldid</p>";
+ wfProfileOut( $fname );
+ return $comment . $diffText;
}
+
if( $row->rc_last_oldid ) {
wfProfileIn( "$fname-dodiff" );
- $oldrow = $dbr->selectRow( 'old',
- array( 'old_flags', 'old_text' ),
- array( 'old_id' => $row->rc_last_oldid ) );
- $oldtext = Article::getRevisionText( $oldrow );
-
+ $oldrev =& Revision::newFromId( $row->rc_last_oldid );
+ if( !$oldrev ) {
+ $diffText = "<p>Can't load old revision $row->rc_last_oldid</p>";
+ wfProfileOut( $fname );
+ return $comment . $diffText;
+ }
+ $oldtext = $oldrev->getText();
+
global $wgFeedDiffCutoff;
if( strlen( $newtext ) > $wgFeedDiffCutoff ||
- strlen( $oldtext ) > $wgFeedDiffCutoff ) {
- $titleObj = Title::makeTitle( $row->rc_namespace, $row->rc_title );
+ strlen( $oldtext ) > $wgFeedDiffCutoff ) {
$diffLink = $titleObj->escapeFullUrl(
'diff=' . $row->rc_this_oldid .
'&oldid=' . $row->rc_last_oldid );
- $diffText = '<a href="' .
- $diffLink .
- '">' .
- htmlspecialchars( wfMsgForContent( 'difference' ) ) .
- '</a>';
+ $diffText = '<a href="' .
+ $diffLink .
+ '">' .
+ htmlspecialchars( wfMsgForContent( 'difference' ) ) .
+ '</a>';
} else {
$diffText = DifferenceEngine::getDiff( $oldtext, $newtext,
wfMsg( 'revisionasof', $wgContLang->timeanddate( $row->rc_timestamp ) ),
*/
require_once( 'SearchEngine.php' );
+require_once( 'Revision.php' );
function wfSpecialSearch( $par='' ) {
global $wgRequest, $wgUser;
if ( '' == $contextchars ) { $contextchars = 50; }
$link = $sk->makeKnownLinkObj( $t, '' );
- $text = Article::getRevisionText( $row );
+ $text = Revision::getRevisionText( $row );
$size = wfMsg( 'nbytes', strlen( $text ) );
$lines = explode( "\n", $text );
* @subpackage SpecialPage
*/
+require_once( 'Revision.php' );
+
/**
*
*/
array( 'ar_namespace' => $this->title->getNamespace(),
'ar_title' => $this->title->getDbkey(),
'ar_timestamp' => $dbr->timestamp( $timestamp ) ) );
- return Article::getRevisionText( $row, "ar_" );
+ return Revision::getRevisionText( $row, "ar_" );
}
/**
'PageArchive::getLastRevisionText',
'ORDER BY ar_timestamp DESC LIMIT 1' );
if( $row ) {
- return Article::getRevisionText( $row, "ar_" );
+ return Revision::getRevisionText( $row, "ar_" );
} else {
return NULL;
}
if( $restoreAll ) {
$max = $s->ar_timestamp;
}
- $text = Article::getRevisionText( $s, "ar_" );
+ $text = Revision::getRevisionText( $s, "ar_" );
$redirect = MagicWord::get( MAG_REDIRECT );
$redir = $redirect->matchStart( $text ) ? 1 : 0;
* @subpackage Maintenance
*/
+require_once( '../includes/Revision.php' );
+
/** */
function compressOldPages( $start = 0 ) {
$fname = 'compressOldPages';
$fname,
'FOR UPDATE'
);
- $text = Article::getRevisionText( $textRow );
+ $text = Revision::getRevisionText( $textRow );
} else {
- $text = Article::getRevisionText( $revs[$i + $j] );
+ $text = Revision::getRevisionText( $revs[$i + $j] );
}
if ( $text === false ) {
$row->old_text = 'This is a bunch of revision text.';
$this->assertEquals(
'This is a bunch of revision text.',
- Article::getRevisionText( $row ) );
+ Revision::getRevisionText( $row ) );
}
function testGetRevisionTextGzip() {
$row->old_text = gzdeflate( 'This is a bunch of revision text.' );
$this->assertEquals(
'This is a bunch of revision text.',
- Article::getRevisionText( $row ) );
+ Revision::getRevisionText( $row ) );
}
function testGetRevisionTextUtf8Native() {
$GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
$this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
- Article::getRevisionText( $row ) );
+ Revision::getRevisionText( $row ) );
}
function testGetRevisionTextUtf8Legacy() {
$GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
$this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
- Article::getRevisionText( $row ) );
+ Revision::getRevisionText( $row ) );
}
function testGetRevisionTextUtf8NativeGzip() {
$GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
$this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
- Article::getRevisionText( $row ) );
+ Revision::getRevisionText( $row ) );
}
function testGetRevisionTextUtf8LegacyGzip() {
$GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
$this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
- Article::getRevisionText( $row ) );
+ Revision::getRevisionText( $row ) );
}
function testCompressRevisionTextUtf8() {
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
- $row->old_flags = Article::compressRevisionText( $row->old_text );
+ $row->old_flags = Revision::compressRevisionText( $row->old_text );
$this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ),
"Flags should contain 'utf-8'" );
$this->assertFalse( false !== strpos( $row->old_flags, 'gzip' ),
$this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
$row->old_text, "Direct check" );
$this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
- Article::getRevisionText( $row ), "getRevisionText" );
+ Revision::getRevisionText( $row ), "getRevisionText" );
}
function testCompressRevisionTextLatin1() {
$GLOBALS['wgUseLatin1'] = true;
$row->old_text = "Wiki est l'\xe9cole superieur !";
- $row->old_flags = Article::compressRevisionText( $row->old_text );
+ $row->old_flags = Revision::compressRevisionText( $row->old_text );
$this->assertFalse( false !== strpos( $row->old_flags, 'utf-8' ),
"Flags should not contain 'utf-8'" );
$this->assertFalse( false !== strpos( $row->old_flags, 'gzip' ),
$this->assertEquals( "Wiki est l'\xe9cole superieur !",
$row->old_text, "Direct check" );
$this->assertEquals( "Wiki est l'\xe9cole superieur !",
- Article::getRevisionText( $row ), "getRevisionText" );
+ Revision::getRevisionText( $row ), "getRevisionText" );
}
function testCompressRevisionTextUtf8Gzip() {
$GLOBALS['wgCompressRevisions'] = true;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
- $row->old_flags = Article::compressRevisionText( $row->old_text );
+ $row->old_flags = Revision::compressRevisionText( $row->old_text );
$this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ),
"Flags should contain 'utf-8'" );
$this->assertTrue( false !== strpos( $row->old_flags, 'gzip' ),
$this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
gzinflate( $row->old_text ), "Direct check" );
$this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
- Article::getRevisionText( $row ), "getRevisionText" );
+ Revision::getRevisionText( $row ), "getRevisionText" );
}
function testCompressRevisionTextLatin1Gzip() {
$GLOBALS['wgUseLatin1'] = true;
$row = new stdClass;
$row->old_text = "Wiki est l'\xe9cole superieur !";
- $row->old_flags = Article::compressRevisionText( $row->old_text );
+ $row->old_flags = Revision::compressRevisionText( $row->old_text );
$this->assertFalse( false !== strpos( $row->old_flags, 'utf-8' ),
"Flags should not contain 'utf-8'" );
$this->assertTrue( false !== strpos( $row->old_flags, 'gzip' ),
$this->assertEquals( "Wiki est l'\xe9cole superieur !",
gzinflate( $row->old_text ), "Direct check" );
$this->assertEquals( "Wiki est l'\xe9cole superieur !",
- Article::getRevisionText( $row ), "getRevisionText" );
+ Revision::getRevisionText( $row ), "getRevisionText" );
}
}