From 64ac6b8e775dd8582ea9cc5f24235488f076c5b3 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 19 Dec 2004 08:00:50 +0000 Subject: [PATCH] Merge SCHEMA_WORK into HEAD. Lots of changes, some things are probably broken: * Page moves/overwrites are a little iffy * Compression might not be working right * Profit! --- RELEASE-NOTES | 2 +- Version.php | 8 - config/index.php | 32 +- includes/Article.php | 550 ++++++++++++--------- includes/CategoryPage.php | 50 +- includes/Database.php | 4 +- includes/DifferenceEngine.php | 43 +- includes/EditPage.php | 42 +- includes/HistoryBlob.php | 2 +- includes/Image.php | 56 ++- includes/ImagePage.php | 17 +- includes/LinkCache.php | 14 +- includes/LinksUpdate.php | 4 +- includes/MessageCache.php | 38 +- includes/OutputPage.php | 1 + includes/PageHistory.php | 62 +-- includes/Parser.php | 31 +- includes/RawPage.php | 14 +- includes/RecentChange.php | 22 +- includes/SearchEngine.php | 2 +- includes/SearchMySQL3.php | 9 +- includes/SearchMySQL4.php | 9 +- includes/Setup.php | 2 +- includes/SpecialAllmessages.php | 8 +- includes/SpecialAllpages.php | 38 +- includes/SpecialAncientpages.php | 16 +- includes/SpecialAsksql.php | 13 +- includes/SpecialBooksources.php | 5 +- includes/SpecialBrokenRedirects.php | 10 +- includes/SpecialContributions.php | 113 ++--- includes/SpecialDeadendpages.php | 10 +- includes/SpecialDisambiguations.php | 12 +- includes/SpecialDoubleRedirects.php | 15 +- includes/SpecialLog.php | 8 +- includes/SpecialLonelypages.php | 8 +- includes/SpecialMaintenance.php | 6 +- includes/SpecialNewpages.php | 14 +- includes/SpecialPopularpages.php | 14 +- includes/SpecialRandompage.php | 16 +- includes/SpecialRecentchangeslinked.php | 27 +- includes/SpecialSearch.php | 7 +- includes/SpecialShortpages.php | 17 +- includes/SpecialStatistics.php | 4 +- includes/SpecialUncategorizedpages.php | 8 +- includes/SpecialWatchlist.php | 25 +- includes/SpecialWhatlinkshere.php | 24 +- includes/SquidUpdate.php | 12 +- includes/Title.php | 276 ++++++----- includes/User.php | 2 +- languages/LanguageUtf8.php | 3 + maintenance/InitialiseMessages.inc | 45 +- maintenance/archives/patch-restructure.sql | 148 ++++++ maintenance/compressOld.inc | 28 +- maintenance/convertUtf8.php | 296 +++++------ maintenance/parserTests.php | 2 +- maintenance/tables.sql | 78 ++- maintenance/updaters.inc | 137 +++++ tests/SearchEngineTest.php | 54 +- tests/SearchMySQL3Test.php | 2 +- tests/SearchMySQL4Test.php | 2 +- 60 files changed, 1436 insertions(+), 1081 deletions(-) delete mode 100644 Version.php create mode 100644 maintenance/archives/patch-restructure.sql diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 5ce29b5895..be4cb6069f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -12,10 +12,10 @@ New exciting things! Need further work and testing... * user groups/permissions scheme * e-mail change notifications * 'live preview' reduces preview reload burden on supported browsers +* Schema reworking: http://meta.wikimedia.org/wiki/Proposed_Database_Schema_Changes/October_2004 * ...and more! Need to merge: -* SCHEMA_WORK * stuff diff --git a/Version.php b/Version.php deleted file mode 100644 index b963890315..0000000000 --- a/Version.php +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/config/index.php b/config/index.php index efed31fa6c..f79af5bb91 100644 --- a/config/index.php +++ b/config/index.php @@ -494,7 +494,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $wgDatabase->selectDB( $wgDBname ); - if( $wgDatabase->tableExists( "cur" ) ) { + if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) { print "
  • There are already MediaWiki tables in this database. Checking if updates are needed...
  • \n"; # Create user if required @@ -556,16 +556,26 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) ); $now = wfTimestampNow(); $won = wfInvertTimestamp( $now ); - $wgDatabase->insert( 'cur', - array( 'cur_namespace' => $titleobj->getNamespace(), - 'cur_title' => $titleobj->getDBkey(), - 'cur_text' => wfMsg( 'mainpagetext' ) . "\n\n" . - wfMsg( 'mainpagedocfooter' ), - 'cur_timestamp' => $now, - 'inverse_timestamp' => $won, - 'cur_touched' => $now, - 'cur_user' => 0, - 'cur_user_text' => 'MediaWiki default' ) ); + + extract( $wgDatabase->tableNames( 'text', 'page', 'revision' ) ); + $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) ); + $title = $titleobj->getDBkey(); + $sql = "INSERT INTO $text (old_text, old_flags) VALUES ('" . + wfStrencode( wfMsg( "mainpagetext" ) . "\n\n" . wfMsg( "mainpagedocfooter" ) ) . + "', '')"; + $wgDatabase->query( $sql, $fname ); + $text_id = $wgDatabase->insertID(); + + $sql = "INSERT INTO $page (page_namespace, page_title, page_restrictions, page_counter, page_is_redirect, + page_is_new, page_random, page_touched, page_latest) VALUES ( + 0, '{$title}', '', 0, 0, 1, 0.5, '{$now}', {$text_id} )"; + $wgDatabase->query( $sql, $fname ); + $page_id = $wgDatabase->insertID(); + + $sql = "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, + rev_timestamp, inverse_timestamp, rev_minor_edit) + VALUES ({$text_id}, {$page_id}, '', 0, 'MediaWiki default', '{$now}', '{$won}', 0)"; + $wgDatabase->query( $sql, $fname ); print "
  • ";
     			initialiseMessages();
    diff --git a/includes/Article.php b/includes/Article.php
    index 572583d12e..afeaacd383 100644
    --- a/includes/Article.php
    +++ b/includes/Article.php
    @@ -32,6 +32,7 @@ class Article {
     	var $mTouched, $mFileCache, $mTitle;
     	var $mId, $mTable;
     	var $mForUpdate;
    +	var $mOldId;
     	/**#@-*/
     
     	/**
    @@ -83,6 +84,7 @@ class Article {
     		if( isset( $row->$textField ) ) {
     			$text = $row->$textField;
     		} else {
    +			wfProfileOut( $fname );
     			return false;
     		}
     
    @@ -272,25 +274,11 @@ class Article {
     	/**
     	 * Return an array of the columns of the "cur"-table
     	 */
    -	function &getCurContentFields() {
    -		global $wgArticleCurContentFields;
    -		if ( !$wgArticleCurContentFields ) {
    -			$wgArticleCurContentFields = array( 'cur_text','cur_timestamp','cur_user', 'cur_user_text',
    -			  'cur_comment','cur_counter','cur_restrictions','cur_touched' );
    -		}
    -		return $wgArticleCurContentFields;
    -	}
    -
    -	/**
    -	 * Return an array of the columns of the "old"-table
    -	 */
    -	function &getOldContentFields() {
    -		global $wgArticleOldContentFields;
    -		if ( !$wgArticleOldContentFields ) {
    -			$wgArticleOldContentFields = array( 'old_namespace','old_title','old_text','old_timestamp',
    -			  'old_user','old_user_text','old_comment','old_flags' );
    -		}
    -		return $wgArticleOldContentFields;
    +	function getContentFields() {
    +		return $wgArticleContentFields = array(
    +		  'old_text','old_flags',
    +		  'rev_timestamp','rev_user', 'rev_user_text', 'rev_comment','page_counter',
    +		  'page_namespace', 'page_title', 'page_restrictions','page_touched','page_is_redirect' );
     	}
     
     	/**
    @@ -301,18 +289,18 @@ class Article {
     	function getOldID() {
     		global $wgRequest, $wgOut;
     		static $lastid;
    -
    +		
     		if ( isset( $lastid ) ) {
     			return $lastid;
     		}
    -
    +		# Query variables :P
     		$oldid = $wgRequest->getVal( 'oldid' );
     		if ( isset( $oldid ) ) {
     			$dbr =& $this->getDB();
     			$oldid = IntVal( $oldid );
     			if ( $wgRequest->getVal( 'direction' ) == 'next' ) {
     				$nextid = $this->mTitle->getNextRevisionID( $oldid );
    -				if ( $nextid ) {
    +				if ( $nextid  ) {
     					$oldid = $nextid;
     				} else {
     					$wgOut->redirect( $this->mTitle->getFullURL( 'redirect=no' ) );
    @@ -333,7 +321,7 @@ class Article {
     
     	/**
     	 * Load the revision (including cur_text) into this object
    -	*/
    +	 */
     	function loadContent( $noredir = false ) {
     		global $wgOut, $wgRequest;
     
    @@ -351,85 +339,117 @@ class Article {
     
     		$t = $this->mTitle->getPrefixedText();
     
    -		if ( isset( $oldid ) ) {
    +		$noredir = $noredir || ($wgRequest->getVal( 'redirect' ) == 'no');
    +		$this->mOldId = $oldid;
    +		$this->fetchContent( $oldid, $noredir, true );
    +	}
    +	
    +	/**
    +	 * @param int $oldid 0 for whatever the latest revision is
    +	 * @param bool $noredir Set to true to avoid following redirects
    +	 * @param bool $globalTitle Set to true to change the global $wgTitle object when following redirects or other unexpected title changes
    +	 * @return string
    +	 */
    +	function fetchContent( $oldid = 0, $noredir = false, $globalTitle = false ) {
    +		if ( $this->mContentLoaded ) {
    +			return $this->mContent;
    +		}
    +		$dbr =& $this->getDB();
    +		$fname = 'Article::fetchContent';
    +
    +		# Pre-fill content with error message so that if something
    +		# fails we'll have something telling us what we intended.
    +		$t = $this->mTitle->getPrefixedText();
    +		if( $oldid ) {
     			$t .= ',oldid='.$oldid;
     		}
    -		if ( isset( $redirect ) ) {
    +		if( isset( $redirect ) ) {
     			$redirect = ($redirect == 'no') ? 'no' : 'yes';
     			$t .= ',redirect='.$redirect;
     		}
     		$this->mContent = wfMsg( 'missingarticle', $t );
     
    -		if ( ! $oldid ) {	# Retrieve current version
    +		if( !$oldid ) {
    +			# Retrieve current version
     			$id = $this->getID();
    -			if ( 0 == $id ) return;
    -
    -			$s = $dbr->selectRow( 'cur', $this->getCurContentFields(), array( 'cur_id' => $id ), $fname,
    -				$this->getSelectOptions() );
    -			if ( $s === false ) {
    -				return;
    +			if ( 0 == $id ) {
    +				return false;
     			}
     
    -			# If we got a redirect, follow it (unless we've been told
    -			# not to by either the function parameter or the query
    -			if ( ( 'no' != $redirect ) && ( false == $noredir ) ) {
    -			  	$rt = Title::newFromRedirect( $s->cur_text );
    -				# 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:
    -					# Fill the HTTP response "Location" header and ignore
    -					# the rest of the page we're on.
    +			$s = $dbr->selectRow( array( 'text', 'revision', 'page' ),
    +				$this->getContentFields(),
    +				"page_id='$id' AND rev_page=page_id AND rev_id=page_latest AND old_id=rev_id",
    +				$fname, $this->getSelectOptions() );
    +		} else {
    +			# Historical revision
    +			$s = $dbr->selectRow( array( 'text', 'revision', 'page' ),
    +				$this->getContentFields(),
    +				"rev_page=page_id AND rev_id='$oldid' AND old_id=rev_id",
    +				$fname, $this->getSelectOptions() );
    +		}
    +		if ( $s === false ) {
    +			return false;
    +		}
     
    +		# 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 ) );
    +			# 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:
    +				# Fill the HTTP response "Location" header and ignore
    +				# the rest of the page we're on.
    +				if( $globalTitle ) {
    +					global $wgOut;
     					if ( $rt->getInterwiki() != '' ) {
     						$wgOut->redirect( $rt->getFullURL() ) ;
    -						return;
    +						return false;
     					}
     					if ( $rt->getNamespace() == NS_SPECIAL ) {
     						$wgOut->redirect( $rt->getFullURL() );
    -						return;
    +						return false;
     					}
    -					$rid = $rt->getArticleID();
    -					if ( 0 != $rid ) {
    -						$redirRow = $dbr->selectRow( 'cur', $this->getCurContentFields(),
    -							array( 'cur_id' => $rid ), $fname, $this->getSelectOptions() );
    -
    -						if ( $redirRow !== false ) {
    -							$this->mRedirectedFrom = $this->mTitle->getPrefixedText();
    -							$this->mTitle = $rt;
    -							$s = $redirRow;
    -						}
    +				}
    +				$rid = $rt->getArticleID();
    +				if ( 0 != $rid ) {
    +					$redirRow = $dbr->selectRow( array( 'text', 'revision', 'page' ),
    +						$this->getContentFields(),
    +						"page_id='$rid' AND rev_page=page_id AND rev_id=page_latest AND old_id=rev_id",
    +						$fname, $this->getSelectOptions() );
    +
    +					if ( $redirRow !== false ) {
    +						$this->mRedirectedFrom = $this->mTitle->getPrefixedText();
    +						$this->mTitle = $rt;
    +						$s = $redirRow;
     					}
     				}
     			}
    +		}
     
    -			$this->mContent = $s->cur_text;
    -			$this->mUser = $s->cur_user;
    -			$this->mUserText = $s->cur_user_text;
    -			$this->mComment = $s->cur_comment;
    -			$this->mCounter = $s->cur_counter;
    -			$this->mTimestamp = wfTimestamp(TS_MW,$s->cur_timestamp);
    -			$this->mTouched = wfTimestamp(TS_MW,$s->cur_touched);
    -			$this->mTitle->loadRestrictions( $s->cur_restrictions );
    -		} else { # oldid set, retrieve historical version
    -			$s = $dbr->selectRow( 'old', $this->getOldContentFields(), array( 'old_id' => $oldid ),
    -				$fname, $this->getSelectOptions() );
    -			if ( $s === false ) {
    -				return;
    -			}
    -
    -			if( $this->mTitle->getNamespace() != $s->old_namespace ||
    -				$this->mTitle->getDBkey() != $s->old_title ) {
    -				$oldTitle = Title::makeTitle( $s->old_namesapce, $s->old_title );
    -				$this->mTitle = $oldTitle;
    -				$wgTitle = $oldTitle;
    -			}
    -			$this->mContent = Article::getRevisionText( $s );
    -			$this->mUser = $s->old_user;
    -			$this->mUserText = $s->old_user_text;
    -			$this->mComment = $s->old_comment;
    -			$this->mCounter = 0;
    -			$this->mTimestamp = wfTimestamp(TS_MW,$s->old_timestamp);
    +		# if the title's different from expected, update...
    +		if( $globalTitle &&
    +			( $this->mTitle->getNamespace() != $s->page_namespace ||
    +			$this->mTitle->getDBkey() != $s->page_title ) ) {
    +			$oldTitle = Title::makeTitle( $s->page_namesapce, $s->page_title );
    +			$this->mTitle = $oldTitle;
    +			global $wgTitle;
    +			$wgTitle = $oldTitle;
     		}
    +		
    +		# Back to the business at hand...
    +		$this->mCounter = $s->page_counter;
    +		$this->mTitle->mRestrictions = explode( ',', trim( $s->page_restrictions ) );
    +		$this->mTitle->mRestrictionsLoaded = true;
    +		$this->mTouched = wfTimestamp( TS_MW, $s->page_touched );
    +
    +		$this->mContent = Article::getRevisionText( $s );
    +		
    +		$this->mUser = $s->rev_user;
    +		$this->mUserText = $s->rev_user_text;
    +		$this->mComment = $s->rev_comment;
    +		$this->mTimestamp = wfTimestamp( TS_MW, $s->rev_timestamp );
    +		
     		$this->mContentLoaded = true;
     		return $this->mContent;
     	}
    @@ -441,68 +461,7 @@ class Article {
     	 * @param integer $oldid
     	 */
     	function getContentWithoutUsingSoManyDamnGlobals( $oldid = 0, $noredir = false ) {
    -		if ( $this->mContentLoaded ) {
    -			return $this->mContent;
    -		}
    -		$this->mContent = false;
    -
    -		$fname = 'Article::getContentWithout';
    -		$dbr =& $this->getDB();
    -
    -		if ( ! $oldid ) {	# Retrieve current version
    -			$id = $this->getID();
    -			if ( 0 == $id ) {
    -				return false;
    -			}
    -
    -			$s = $dbr->selectRow( 'cur', $this->getCurContentFields(), array( 'cur_id' => $id ),
    -				$fname, $this->getSelectOptions() );
    -			if ( $s === false ) {
    -				return false;
    -			}
    -
    -			# If we got a redirect, follow it (unless we've been told
    -			# not to by either the function parameter or the query
    -			if ( !$noredir ) {
    -				$rt = Title::newFromRedirect( $s->cur_text );
    -				if( $rt &&  $rt->getInterwiki() == '' && $rt->getNamespace() != NS_SPECIAL ) {
    -					$rid = $rt->getArticleID();
    -					if ( 0 != $rid ) {
    -						$redirRow = $dbr->selectRow( 'cur', $this->getCurContentFields(),
    -							array( 'cur_id' => $rid ), $fname, $this->getSelectOptions() );
    -
    -						if ( $redirRow !== false ) {
    -							$this->mRedirectedFrom = $this->mTitle->getPrefixedText();
    -							$this->mTitle = $rt;
    -							$s = $redirRow;
    -						}
    -					}
    -				}
    -			}
    -
    -			$this->mContent = $s->cur_text;
    -			$this->mUser = $s->cur_user;
    -			$this->mUserText = $s->cur_user_text;
    -			$this->mComment = $s->cur_comment;
    -			$this->mCounter = $s->cur_counter;
    -			$this->mTimestamp = wfTimestamp(TS_MW,$s->cur_timestamp);
    -			$this->mTouched = wfTimestamp(TS_MW,$s->cur_touched);
    -			$this->mTitle->loadRestrictions( $s->cur_restrictions );
    -		} else { # oldid set, retrieve historical version
    -			$s = $dbr->selectRow( 'old', $this->getOldContentFields(), array( 'old_id' => $oldid ),
    -				$fname, $this->getSelectOptions() );
    -			if ( $s === false ) {
    -				return false;
    -			}
    -			$this->mContent = Article::getRevisionText( $s );
    -			$this->mUser = $s->old_user;
    -			$this->mUserText = $s->old_user_text;
    -			$this->mComment = $s->old_comment;
    -			$this->mCounter = 0;
    -			$this->mTimestamp = wfTimestamp(TS_MW,$s->old_timestamp);
    -		}
    -		$this->mContentLoaded = true;
    -		return $this->mContent;
    +		return $this->fetchContent( $oldid, $noredir, false );
     	}
     
     	/**
    @@ -556,7 +515,7 @@ class Article {
     		if ( -1 == $this->mCounter ) {
     			$id = $this->getID();
     			$dbr =& $this->getDB();
    -			$this->mCounter = $dbr->selectField( 'cur', 'cur_counter', 'cur_id='.$id,
    +			$this->mCounter = $dbr->selectField( 'page', 'page_counter', array( 'page_id' => $id ),
     				'Article::getCount', $this->getSelectOptions() );
     		}
     		return $this->mCounter;
    @@ -590,27 +549,29 @@ class Article {
     	}
     
     	/**
    -	 * Loads everything from cur except cur_text
    +	 * Loads everything except the text
     	 * This isn't necessary for all uses, so it's only done if needed.
     	 * @private
     	 */
     	function loadLastEdit() {
     		global $wgOut;
    -		if ( -1 != $this->mUser ) return;
    +
    +		if ( -1 != $this->mUser )
    +			return;
     
     		$fname = 'Article::loadLastEdit';
     
     		$dbr =& $this->getDB();
    -		$s = $dbr->selectRow( 'cur',
    -		  array( 'cur_user','cur_user_text','cur_timestamp', 'cur_comment','cur_minor_edit' ),
    -		  array( 'cur_id' => $this->getID() ), $fname, $this->getSelectOptions() );
    +		$s = $dbr->selectRow( array( 'revision', 'page') ,
    +		  array( 'rev_user','rev_user_text','rev_timestamp', 'rev_comment','rev_minor_edit' ),
    +		  array( 'page_id' => $this->getID(), 'page_latest=rev_id' ), $fname, $this->getSelectOptions() );
     
     		if ( $s !== false ) {
    -			$this->mUser = $s->cur_user;
    -			$this->mUserText = $s->cur_user_text;
    -			$this->mTimestamp = wfTimestamp(TS_MW,$s->cur_timestamp);
    -			$this->mComment = $s->cur_comment;
    -			$this->mMinorEdit = $s->cur_minor_edit;
    +			$this->mUser = $s->rev_user;
    +			$this->mUserText = $s->rev_user_text;
    +			$this->mTimestamp = wfTimestamp(TS_MW,$s->rev_timestamp);
    +			$this->mComment = $s->rev_comment;
    +			$this->mMinorEdit = $s->rev_minor_edit;
     		}
     	}
     
    @@ -647,18 +608,17 @@ class Article {
     		$title = $this->mTitle;
     		$contribs = array();
     		$dbr =& $this->getDB();
    -		$oldTable = $dbr->tableName( 'old' );
    +		$revTable = $dbr->tableName( 'revision' );
     		$userTable = $dbr->tableName( 'user' );
     		$encDBkey = $dbr->addQuotes( $title->getDBkey() );
     		$ns = $title->getNamespace();
     		$user = $this->getUser();
     
    -		$sql = "SELECT old_user, old_user_text, user_real_name, MAX(old_timestamp) as timestamp
    -			FROM $oldTable LEFT JOIN $userTable ON old_user = user_id
    -			WHERE old_namespace = $user
    -			AND old_title = $encDBkey
    +		$sql = "SELECT rev_user, rev_user_text, user_real_name, MAX(rev_timestamp) as timestamp
    +			FROM $revTable LEFT JOIN $userTable ON rev_user = user_id
    +			WHERE rev_page = $pageId
     			AND old_user != $user
    -			GROUP BY old_user, old_user_text, user_real_name
    +			GROUP BY rev_user, rev_user_text, user_real_name
     			ORDER BY timestamp DESC";
     
     		if ($limit > 0) { $sql .= ' LIMIT '.$limit; }
    @@ -667,7 +627,7 @@ class Article {
     		$res = $dbr->query($sql, $fname);
     
     		while ( $line = $dbr->fetchObject( $res ) ) {
    -			$contribs[] = array($line->old_user, $line->old_user_text, $line->user_real_name);
    +			$contribs[] = array($line->rev_user, $line->rev_user_text, $line->user_real_name);
     		}
     
     		$dbr->freeResult($res);
    @@ -747,7 +707,7 @@ class Article {
     			# We're looking at an old revision
     
     			if ( !empty( $oldid ) ) {
    -				$this->setOldSubtitle( $oldid );
    +				$this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid );
     				$wgOut->setRobotpolicy( 'noindex,follow' );
     			}
     			if ( '' != $this->mRedirectedFrom ) {
    @@ -836,32 +796,47 @@ class Article {
     		$won = wfInvertTimestamp( $now );
     		wfSeedRandom();
     		$rand = wfRandom();
    -		$dbw =& wfGetDB( DB_MASTER );
    +		$isminor = ( $isminor && $wgUser->getID() ) ? 1 : 0;
    +		
    +		$mungedText = $text;
    +		$flags = Article::compressRevisionText( $mungedText );
     
    -		$cur_id = $dbw->nextSequenceValue( 'cur_cur_id_seq' );
    +		$dbw =& wfGetDB( DB_MASTER );
     
    -		$isminor = ( $isminor && $wgUser->getID() ) ? 1 : 0;
    +		$old_id = $dbw->nextSequenceValue( 'text_old_id_seq' );
    +		$dbw->insert( 'text', array(
    +			'old_id' => $old_id,
    +			'old_text' => $mungedText,
    +			'old_flags' => $flags,
    +		), $fname );
    +		$revisionId = $dbw->insertId();
    +		
    +		$page_id = $dbw->nextSequenceValue( 'page_page_id_seq' );
    +		$dbw->insert( 'page', array(
    +			'page_id' => $page_id,
    +			'page_namespace' => $ns,
    +			'page_title' => $ttl,
    +			'page_counter' => 0,
    +			'page_restrictions' => '',
    +			'page_is_redirect' => $redir,
    +			'page_is_new' => 1,
    +			'page_random' => $rand,
    +			'page_touched' => $dbw->timestamp($now),
    +			'page_latest' => $revisionId,
    +		), $fname );
    +		$newid = $dbw->insertId();
     
    -		$dbw->insert( 'cur', array(
    -			'cur_id' => $cur_id,
    -			'cur_namespace' => $ns,
    -			'cur_title' => $ttl,
    -			'cur_text' => $text,
    -			'cur_comment' => $summary,
    -			'cur_user' => $wgUser->getID(),
    -			'cur_timestamp' => $dbw->timestamp($now),
    -			'cur_minor_edit' => $isminor,
    -			'cur_counter' => 0,
    -			'cur_restrictions' => '',
    -			'cur_user_text' => $wgUser->getName(),
    -			'cur_is_redirect' => $redir,
    -			'cur_is_new' => 1,
    -			'cur_random' => $rand,
    -			'cur_touched' => $dbw->timestamp($now),
    +		$dbw->insert( 'revision', array(
    +			'rev_page' => $newid,
    +			'rev_id' => $revisionId,
    +			'rev_comment' => $summary,
    +			'rev_user' => $wgUser->getID(),
    +			'rev_timestamp' => $dbw->timestamp($now),
    +			'rev_minor_edit' => $isminor,
    +			'rev_user_text' => $wgUser->getName(),
     			'inverse_timestamp' => $won,
     		), $fname );
     
    -		$newid = $dbw->insertId();
     		$this->mTitle->resetArticleID( $newid );
     
     		Article::onArticleCreate( $this->mTitle );
    @@ -877,8 +852,11 @@ class Article {
     
     		# The talk page isn't in the regular link tables, so we need to update manually:
     		$talkns = $ns ^ 1; # talk -> normal; normal -> talk
    -		$dbw->update( 'cur', array('cur_touched' => $dbw->timestamp($now) ),
    -			array(  'cur_namespace' => $talkns, 'cur_title' => $ttl ), $fname );
    +		$dbw->update( 'page',
    +			array( 'page_touched' => $dbw->timestamp($now) ),
    +			array( 'page_namespace' => $talkns,
    +			       'page_title' => $ttl ),
    +			$fname );
     
     		# standard deferred updates
     		$this->editUpdates( $text, $summary, $isminor, $now );
    @@ -887,25 +865,42 @@ class Article {
     		$this->showArticle( $text, wfMsg( 'newarticle' ), false, $isminor, $now, $summary, $oldid );
     	}
     
    -
     	/**
    -	 * Side effects: loads last edit if $edittime is NULL
    +	 * Fetch and uncompress the text for a given revision.
    +	 * Can ask by rev_id number or timestamp (set $field)
     	 */
    +	function fetchRevisionText( $revId = null, $field = 'rev_id' ) {
    +		$fname = 'Article::fetchRevisionText';
    +		$dbw =& wfGetDB( DB_MASTER );
    +		if( $revId ) {
    +			$rev = $dbw->addQuotes( $revId );
    +		} else {
    +			$rev = 'page_latest';
    +		}
    +		$result = $dbw->query(
    +			sprintf( "SELECT old_text, old_flags
    +				FROM %s,%s,%s
    +				WHERE old_id=rev_id AND rev_page=page_id AND page_id=%d
    +				AND %s=%s",
    +				$dbw->tableName( 'page' ),
    +				$dbw->tableName( 'revision' ),
    +				$dbw->tableName( 'text' ),
    +				IntVal( $this->mTitle->getArticleId() ),
    +				$field,
    +				$rev ),
    +			$fname );
    +		$obj = $dbw->fetchObject( $result );
    +		$dbw->freeResult( $result );
    +		$oldtext = Article::getRevisionText( $obj );
    +		return $oldtext;
    +	}
    +	
     	function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = '', $edittime = NULL) {
     		$fname = 'Article::getTextOfLastEditWithSectionReplacedOrAdded';
    -		if(is_null($edittime)) {
    -			$this->loadLastEdit();
    -			$oldtext = $this->getContent( true );
    +		if( is_null( $edittime ) ) {
    +			$oldtext = $this->fetchRevisionText();
     		} else {
    -			$dbw =& wfGetDB( DB_MASTER );
    -			$ns = $this->mTitle->getNamespace();
    -			$title = $this->mTitle->getDBkey();
    -			$obj = $dbw->selectRow( 'old', 
    -				array( 'old_text','old_flags'), 
    -				array( 'old_namespace' => $ns, 'old_title' => $title, 
    -					'old_timestamp' => $dbw->timestamp($edittime)),
    -				$fname );
    -			$oldtext = Article::getRevisionText( $obj );
    +			$oldtext = $this->fetchRevisionText( $edittime, 'rev_timestamp' );
     		}
     		if ($section != '') {
     			if($section=='new') {
    @@ -1030,22 +1025,47 @@ class Article {
     			$now = wfTimestampNow();
     			$won = wfInvertTimestamp( $now );
     
    -			# First update the cur row
    -			$dbw->update( 'cur',
    -				array( /* SET */
    -					'cur_text' => $text,
    -					'cur_comment' => $summary,
    -					'cur_minor_edit' => $me2,
    -					'cur_user' => $wgUser->getID(),
    -					'cur_timestamp' => $dbw->timestamp($now),
    -					'cur_user_text' => $wgUser->getName(),
    -					'cur_is_redirect' => $redir,
    -					'cur_is_new' => 0,
    -					'cur_touched' => $dbw->timestamp($now),
    +			$mungedText = $text;
    +			$flags = Article::compressRevisionText( $newtext );
    +			
    +			$lastRevision = $dbw->selectField(
    +				'page', 'page_latest', array( 'page_id' => $this->getId() ) );
    +			
    +			# Record the text to the text table
    +			$old_id = $dbw->nextSequenceValue( 'text_old_id_val' );
    +			$dbw->insert( 'text',
    +				array(
    +					'old_id' => $old_id,
    +					'old_text' => $mungedText,
    +					'old_flags' => $flags,
    +				), $fname
    +			);
    +			$revisionId = $dbw->insertId();
    +			
    +			# Record the edit in revisions
    +			$dbw->insert( 'revision',
    +				array(
    +					'rev_id' => $revisionId,
    +					'rev_page' => $this->getID(),
    +					'rev_comment' => $summary,
    +					'rev_minor_edit' => $me2,
    +					'rev_user' => $wgUser->getID(),
    +					'rev_user_text' => $wgUser->getName(),
    +					'rev_timestamp' => $dbw->timestamp( $now ),
     					'inverse_timestamp' => $won
    +				), $fname
    +			);
    +			
    +			# Update page
    +			$dbw->update( 'page',
    +				array( /* SET */
    +					'page_latest' => $revisionId,
    +					'page_touched' => $dbw->timestamp( $now ),
    +					'page_is_new' => 0,
    +					'page_is_redirect' => $redir,
     				), array( /* WHERE */
    -					'cur_id' => $this->getID(),
    -					'cur_timestamp' => $dbw->timestamp($this->getTimestamp())
    +					'page_id' => $this->getID(),
    +					'page_latest' => $lastRevision, # Paranoia
     				), $fname
     			);
     
    @@ -1053,32 +1073,10 @@ class Article {
     				/* Belated edit conflict! Run away!! */
     				$good = false;
     			} else {
    -				# Now insert the previous revision into old
    -
    -				# This overwrites $oldtext if revision compression is on
    -				$flags = Article::compressRevisionText( $oldtext );
    -
    -				$dbw->insert( 'old',
    -					array(
    -						'old_id' => $dbw->nextSequenceValue( 'old_old_id_seq' ),
    -						'old_namespace' => $this->mTitle->getNamespace(),
    -						'old_title' => $this->mTitle->getDBkey(),
    -						'old_text' => $oldtext,
    -						'old_comment' => $this->getComment(),
    -						'old_user' => $this->getUser(),
    -						'old_user_text' => $this->getUserText(),
    -						'old_timestamp' => $dbw->timestamp($this->getTimestamp()),
    -						'old_minor_edit' => $me1,
    -						'inverse_timestamp' => wfInvertTimestamp( $this->getTimestamp() ),
    -						'old_flags' => $flags,
    -					), $fname
    -				);
    -
    -				$oldid = $dbw->insertId();
    -
    +				# Update recentchanges and purge cache and whatnot
     				$bot = (int)($wgUser->isBot() || $forceBot);
     				RecentChange::notifyEdit( $now, $this->mTitle, $me2, $wgUser, $summary,
    -					$oldid, $this->getTimestamp(), $bot );
    +					$lastRevision, $this->getTimestamp(), $bot );
     				Article::onArticleEdit( $this->mTitle );
     			}
     		}
    @@ -1121,7 +1119,7 @@ class Article {
     			$u->doUpdate();
     		}
     
    -		$this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $me2, $now, $summary, $oldid );
    +		$this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $me2, $now, $summary, $revisionId );
     		}
     		return $good;
     	}
    @@ -1317,6 +1315,15 @@ class Article {
     		$reason = $wgRequest->getText( 'wpReasonProtect' );
     
     		if ( $confirm ) {
    +			$dbw =& wfGetDB( DB_MASTER );
    +			$dbw->update( 'page',
    +				array( /* SET */
    +					'page_touched' => $dbw->timestamp(),
    +					'page_restrictions' => (string)$limit
    +				), array( /* WHERE */
    +					'page_id' => $id
    +				), 'Article::protect'
    +			);
     
     			$restrictions = "move=" . $limit;
     			if( !$moveonly ) {
    @@ -2010,11 +2017,11 @@ class Article {
     		$fname = 'Article::checkTouched';
     		$id = $this->getID();
     		$dbr =& $this->getDB();
    -		$s = $dbr->selectRow( 'cur', array( 'cur_touched', 'cur_is_redirect' ),
    -			array( 'cur_id' => $id ), $fname, $this->getSelectOptions() );
    +		$s = $dbr->selectRow( 'page', array( 'page_touched', 'page_is_redirect' ),
    +			array( 'page_id' => $id ), $fname, $this->getSelectOptions() );
     		if( $s !== false ) {
    -			$this->mTouched = wfTimestamp(TS_MW,$s->cur_touched);
    -			return !$s->cur_is_redirect;
    +			$this->mTouched = wfTimestamp( TS_MW, $s->page_touched );
    +			return !$s->page_is_redirect;
     		} else {
     			return false;
     		}
    @@ -2030,6 +2037,9 @@ class Article {
     	function quickEdit( $text, $comment = '', $minor = 0 ) {
     		global $wgUser;
     		$fname = 'Article::quickEdit';
    +
    +		#wfDebugDieBacktrace( "$fname called." );
    +
     		wfProfileIn( $fname );
     
     		$dbw =& wfGetDB( DB_MASTER );
    @@ -2037,7 +2047,34 @@ class Article {
     		$dbkey = $this->mTitle->getDBkey();
     		$encDbKey = $dbw->strencode( $dbkey );
     		$timestamp = wfTimestampNow();
    -
    +		# insert new text
    +		$dbw->insert( 'text', array(
    +				'old_text' => $text,
    +				'old_flags' => "" ), $fname );
    +		$text_id = $dbw->insertID();
    +
    +		# update page
    +		$dbw->update( 'page', array(
    +			'page_is_new' => 0,
    +			'page_touched' => $timestamp,
    +			'page_is_redirect' => $this->isRedirect( $text ) ? 1 : 0,
    +			'page_latest' => $text_id ),
    +			array( 'page_namespace' => $ns, 'page_title' => $dbkey ), $fname );
    +		# Retrieve page ID
    +		$page_id = $dbw->selectField( 'page', 'page_id', array( 'page_namespace' => $ns, 'page_title' => $dbkey ), $fname );
    +
    +		# update revision
    +		$dbw->insert( 'revision', array(
    +			'rev_id' => $text_id,
    +			'rev_page' => $page_id,
    +			'rev_comment' => $comment,
    +			'rev_user' => $wgUser->getID(),
    +			'rev_user_text' => $wgUser->getName(),
    +			'rev_timestamp' => $timestamp,
    +			'inverse_timestamp' => wfInvertTimestamp( $timestamp ),
    +			'rev_minor_edit' => intval($minor) ),
    +			$fname );
    +/*
     		# Save to history
     		$dbw->insertSelect( 'old', 'cur',
     			array(
    @@ -2083,6 +2120,7 @@ class Article {
     			$fields['cur_random'] = $rand = wfRandom();
     			$dbw->insert( 'cur', $fields, $fname );
     		}
    +*/
     		wfProfileOut( $fname );
     	}
     
    @@ -2097,12 +2135,12 @@ class Article {
     		global $wgHitcounterUpdateFreq;
     
     		$dbw =& wfGetDB( DB_MASTER );
    -		$curTable = $dbw->tableName( 'cur' );
    +		$pageTable = $dbw->tableName( 'page' );
     		$hitcounterTable = $dbw->tableName( 'hitcounter' );
     		$acchitsTable = $dbw->tableName( 'acchits' );
     
     		if( $wgHitcounterUpdateFreq <= 1 ){ //
    -			$dbw->query( "UPDATE $curTable SET cur_counter = cur_counter + 1 WHERE cur_id = $id" );
    +			$dbw->query( "UPDATE $pageTable SET page_counter = page_counter + 1 WHERE page_id = $id" );
     			return;
     		}
     
    @@ -2255,4 +2293,30 @@ class Article {
     	}
     }
     
    +/**
    + * Check whether an article is a stub
    + *
    + * @public
    + * @param integer $articleID	ID of the article that is to be checked
    + */
    +function wfArticleIsStub( $articleID ) {
    +	global $wgUser;
    +	$fname = 'wfArticleIsStub';
    +
    +	$threshold = $wgUser->getOption('stubthreshold') ;
    +	if ( $threshold > 0 ) {
    +		$dbr =& wfGetDB( DB_SLAVE );
    +		$s = $dbr->selectRow( array('page', 'text'),
    +			array( 'LENGTH(old_text) AS len', 'page_namespace', 'page_is_redirect' ),
    +			array( 'page_id' => $articleID, "page.page_latest=text.old_id" ),
    +			$fname ) ;
    +		if ( $s == false OR $s->page_is_redirect OR $s->page_namespace != 0 ) {
    +			return false;
    +		}
    +		$size = $s->len;
    +		return ( $size < $threshold );
    +	}
    +	return false;
    +}
    +
     ?>
    diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php
    index cb749cf4f3..2bed882d22 100644
    --- a/includes/CategoryPage.php
    +++ b/includes/CategoryPage.php
    @@ -69,24 +69,24 @@ class CategoryPage extends Article {
     
     		# FIXME: add limits
     		$dbr =& wfGetDB( DB_SLAVE );
    -		$cur = $dbr->tableName( 'cur' );
    +		$page = $dbr->tableName( 'page' );
     		$categorylinks = $dbr->tableName( 'categorylinks' );
     
     		$t = $dbr->strencode( $this->mTitle->getDBKey() );
    -		$sql = "SELECT DISTINCT cur_title,cur_namespace FROM $cur,$categorylinks " .
    -			"WHERE cl_to='$t' AND cl_from=cur_id AND cur_is_redirect=0 ORDER BY cl_sortkey" ;
    +		$sql = "SELECT DISTINCT page_title, page_namespace FROM $page,$categorylinks " .
    +				"WHERE cl_to='$t' AND cl_from=page_id AND page_is_redirect=0 ORDER BY cl_sortkey" ;
     		$res = $dbr->query( $sql, $fname ) ;
     		# For all pages that link to this category
     		while ( $x = $dbr->fetchObject ( $res ) )
     		{
    -			$t = $wgContLang->getNsText ( $x->cur_namespace ) ;
    +			$t = $wgContLang->getNsText ( $x->page_namespace ) ;
     			if ( $t != '' ) $t .= ':' ;
    -			$t .= $x->cur_title ;
    +			$t .= $x->page_title ;
     
    -			if ( $x->cur_namespace == NS_CATEGORY ) {
    -				array_push ( $children , $sk->makeLink ( $t ) ) ; # Subcategory
    +			if ( $x->page_namespace == NS_CATEGORY ) {
    +					array_push ( $children , $sk->makeLink ( $t ) ) ; # Subcategory
     			} else {
    -				array_push ( $articles , $sk->makeLink ( $t ) ) ; # Page in this category
    +					array_push ( $articles , $sk->makeLink ( $t ) ) ; # Page in this category
     			}
     		}
     		$dbr->freeResult ( $res ) ;
    @@ -105,6 +105,20 @@ class CategoryPage extends Article {
     			$r .= implode ( ', ' , $articles ) ;
     		}
     
    +		# Showing subcategories
    +		if ( count ( $children ) > 0 ) {
    +			$r .= '

    '.wfMsg('subcategories')."

    \n" ; + $r .= implode ( ', ' , $children ) ; + } + + # Showing pages in this category + if ( count ( $articles ) > 0 ) { + $ti = $this->mTitle->getText() ; + $h = wfMsg( 'category_header', $ti ); + $r .= "

    $h

    \n" ; + $r .= implode ( ', ' , $articles ) ; + } + return $r ; } @@ -128,21 +142,21 @@ class CategoryPage extends Article { # FIXME: add limits $dbr =& wfGetDB( DB_SLAVE ); - $cur = $dbr->tableName( 'cur' ); + $page = $dbr->tableName( 'page' ); $categorylinks = $dbr->tableName( 'categorylinks' ); $t = $dbr->strencode( $this->mTitle->getDBKey() ); - $sql = "SELECT DISTINCT cur_title,cur_namespace,cl_sortkey FROM " . - "$cur,$categorylinks WHERE cl_to='$t' AND cl_from=cur_id AND cur_is_redirect=0 ORDER BY cl_sortkey" ; + $sql = "SELECT DISTINCT page_title,page_namespace,cl_sortkey FROM " . + "$page,$categorylinks WHERE cl_to='$t' AND cl_from=page_id AND page_is_redirect ORDER BY cl_sortkey" ; $res = $dbr->query ( $sql ) ; while ( $x = $dbr->fetchObject ( $res ) ) { - $t = $ns = $wgContLang->getNsText ( $x->cur_namespace ) ; + $t = $ns = $wgContLang->getNsText ( $x->page_namespace ) ; if ( $t != '' ) $t .= ':' ; - $t .= $x->cur_title ; - $ctitle = str_replace( '_',' ',$x->cur_title ); + $t .= $x->page_title ; + $ctitle = str_replace( '_',' ',$x->page_title ); - if ( $x->cur_namespace == NS_CATEGORY ) { + if ( $x->page_namespace == NS_CATEGORY ) { array_push ( $children, $sk->makeKnownLink ( $t, $ctitle ) ) ; # Subcategory // If there's a link from Category:A to Category:B, the sortkey of the resulting @@ -150,12 +164,12 @@ class CategoryPage extends Article { // Workaround: If sortkey == "Category:".$title, than use $title for sorting, // else use sortkey... if ( ($ns.':'.$ctitle) == $x->cl_sortkey ) { - array_push ( $children_start_char, $wgContLang->firstChar( $x->cur_title ) ); + array_push ( $children_start_char, $wgContLang->firstChar( $x->page_title ) ); } else { array_push ( $children_start_char, $wgContLang->firstChar( $x->cl_sortkey ) ) ; } - } elseif ( $wgCategoryMagicGallery && $x->cur_namespace == NS_IMAGE ) { - $ig->add( new Image( $x->cur_title ) ); + } elseif ( $wgCategoryMagicGallery && $x->page_namespace == NS_IMAGE ) { + $ig->add( new Image( $x->page_title ) ); } else { array_push ( $articles , $sk->makeKnownLink ( $t ) ) ; # Page in this category array_push ( $articles_start_char, $wgContLang->firstChar( $x->cl_sortkey ) ) ; diff --git a/includes/Database.php b/includes/Database.php index f42a2cf6a6..6cd4727ebe 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -652,8 +652,8 @@ class Database { * $conds: a condition map, terms are ANDed together. * Items with numeric keys are taken to be literal conditions * Takes an array of selected variables, and a condition map, which is ANDed - * e.g. selectRow( "cur", array( "cur_id" ), array( "cur_namespace" => 0, "cur_title" => "Astronomy" ) ) - * would return an object where $obj->cur_id is the ID of the Astronomy article + * e.g. selectRow( "page", array( "page_id" ), array( "page_namespace" => 0, "page_title" => "Astronomy" ) ) + * would return an object where $obj->page_id is the ID of the Astronomy article * * @todo migrate documentation to phpdocumentor format */ diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 4c6017ef43..360e5f0170 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -259,26 +259,31 @@ class DifferenceEngine { $dbr =& wfGetDB( DB_SLAVE ); if ( 0 == $this->mNewid || 0 == $this->mOldid ) { + /* Fetch current revision */ $wgOut->setArticleFlag( true ); $newLink = $wgTitle->escapeLocalUrl(); $this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev' ) ); $this->mNewtitle = "{$this->mPagetitle}"; $id = $wgTitle->getArticleID(); - $s = $dbr->selectRow( 'cur', array( 'cur_text', 'cur_user_text', 'cur_comment' ), - array( 'cur_id' => $id ), $fname ); + $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 cur_id $id\n" ); + wfDebug( "Unable to load page_id $id\n" ); return false; } $this->mNewPage = &$wgTitle; - $this->mNewtext = $s->cur_text; - $this->mNewUser = $s->cur_user_text; - $this->mNewComment = $s->cur_comment; + $this->mNewtext = Article::getRevisionText( $s ); + $this->mNewUser = $s->rev_user_text; + $this->mNewComment = $s->rev_comment; } else { - $s = $dbr->selectRow( 'old', array( 'old_namespace','old_title','old_timestamp', 'old_text', - 'old_flags','old_user_text','old_comment' ), array( 'old_id' => $this->mNewid ), $fname ); + $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" ); @@ -287,13 +292,13 @@ class DifferenceEngine { $this->mNewtext = Article::getRevisionText( $s ); - $t = $wgLang->timeanddate( $s->old_timestamp, true ); - $this->mNewPage = Title::MakeTitle( $s->old_namespace, $s->old_title ); + $t = $wgLang->timeanddate( $s->rev_timestamp, true ); + $this->mNewPage = Title::MakeTitle( $s->page_namespace, $s->page_title ); $newLink = $wgTitle->escapeLocalUrl ('oldid=' . $this->mNewid); $this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $t ) ); $this->mNewtitle = "{$this->mPagetitle}"; - $this->mNewUser = $s->old_user_text; - $this->mNewComment = $s->old_comment; + $this->mNewUser = $s->rev_user_text; + $this->mNewComment = $s->rev_comment; } if ( 0 == $this->mOldid ) { $s = $dbr->selectRow( 'old', @@ -308,9 +313,9 @@ class DifferenceEngine { return false; } } else { - $s = $dbr->selectRow( 'old', - array( 'old_namespace','old_title','old_timestamp','old_text','old_flags','old_user_text','old_comment'), - array( 'old_id' => $this->mOldid ), + $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 ) { @@ -318,14 +323,14 @@ class DifferenceEngine { return false; } } - $this->mOldPage = Title::MakeTitle( $s->old_namespace, $s->old_title ); + $this->mOldPage = Title::MakeTitle( $s->page_namespace, $s->page_title ); $this->mOldtext = Article::getRevisionText( $s ); - $t = $wgLang->timeanddate( $s->old_timestamp, true ); + $t = $wgLang->timeanddate( $s->rev_timestamp, true ); $oldLink = $this->mOldPage->escapeLocalUrl ('oldid=' . $this->mOldid); $this->mOldtitle = "" . htmlspecialchars( wfMsg( 'revisionasof', $t ) ) . ''; - $this->mOldUser = $s->old_user_text; - $this->mOldComment = $s->old_comment; + $this->mOldUser = $s->rev_user_text; + $this->mOldComment = $s->rev_comment; return true; } diff --git a/includes/EditPage.php b/includes/EditPage.php index 0f4e779f1b..33e17c9401 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -434,17 +434,17 @@ class EditPage { } # Prepare a list of templates used by this page $db =& wfGetDB( DB_SLAVE ); - $cur = $db->tableName( 'cur' ); + $page = $db->tableName( 'page' ); $links = $db->tableName( 'links' ); $id = $this->mTitle->getArticleID(); - $sql = "SELECT cur_namespace,cur_title,cur_id ". - "FROM $cur,$links WHERE l_to=cur_id AND l_from={$id} and cur_namespace=".NS_TEMPLATE; + $sql = "SELECT page_namespace,page_title,page_id ". + "FROM $page,$links WHERE l_to=page_id AND l_from={$id} and page_namespace=".NS_TEMPLATE; $res = $db->query( $sql, "EditPage::editform" ); if ( $db->numRows( $res ) ) { $templates = '
    '. wfMsg( 'templatesused' ) . '