From: Domas Mituzas Date: Mon, 21 Feb 2005 15:33:58 +0000 (+0000) Subject: remove inverse_timestamp wherever it is found and disable wfInvertTimestamp() X-Git-Tag: 1.5.0alpha1~704 X-Git-Url: http://git.cyclocoop.org/wiki/Target_page?a=commitdiff_plain;h=0aa2629efc67b65d661df536f2c0f2fed59f3d64;p=lhc%2Fweb%2Fwiklou.git remove inverse_timestamp wherever it is found and disable wfInvertTimestamp() dear mysql3, try to remember how beautiful filesorts are, you're so good at it. --- diff --git a/config/index.php b/config/index.php index e612bf397f..9bf0a80b91 100644 --- a/config/index.php +++ b/config/index.php @@ -583,8 +583,8 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $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)"; + rev_timestamp, rev_minor_edit) + VALUES ({$text_id}, {$page_id}, '', 0, 'MediaWiki default', '{$now}', 0)"; $wgDatabase->query( $sql, $fname ); print "
  • ";
    diff --git a/includes/Article.php b/includes/Article.php
    index b8f603ffa6..6c35655151 100644
    --- a/includes/Article.php
    +++ b/includes/Article.php
    @@ -718,7 +718,6 @@ class Article {
     		else { $redir = 0; }
     
     		$now = wfTimestampNow();
    -		$won = wfInvertTimestamp( $now );
     		wfSeedRandom();
     		$rand = wfRandom();
     		$isminor = ( $isminor && $wgUser->isLoggedIn() ) ? 1 : 0;
    @@ -759,7 +758,6 @@ class Article {
     			'rev_timestamp' => $dbw->timestamp($now),
     			'rev_minor_edit' => $isminor,
     			'rev_user_text' => $wgUser->getName(),
    -			'inverse_timestamp' => $won,
     		), $fname );
     
     		$this->mTitle->resetArticleID( $newid );
    @@ -948,7 +946,6 @@ class Article {
     			$this->mCountAdjustment = $this->isCountable( $text )
     			  - $this->isCountable( $oldtext );
     			$now = wfTimestampNow();
    -			$won = wfInvertTimestamp( $now );
     
     			$mungedText = $text;
     			$flags = Revision::compressRevisionText( $mungedText );
    @@ -977,7 +974,6 @@ class Article {
     					'rev_user' => $wgUser->getID(),
     					'rev_user_text' => $wgUser->getName(),
     					'rev_timestamp' => $dbw->timestamp( $now ),
    -					'inverse_timestamp' => $won
     				), $fname
     			);
     			
    @@ -1401,7 +1397,7 @@ class Article {
     				'page_namespace' => $ns,
     				'page_title' => $title,
     				'rev_page = page_id'
    -			), $fname, $this->getSelectOptions( array( 'ORDER BY' => 'inverse_timestamp' ) )
    +			), $fname, $this->getSelectOptions( array( 'ORDER BY' => 'rev_timestamp DESC' ) )
     		);
     
     		if( $dbr->numRows( $revisions ) > 1 && !$confirm ) {
    @@ -1975,7 +1971,6 @@ class Article {
     			'rev_user' => $wgUser->getID(),
     			'rev_user_text' => $wgUser->getName(),
     			'rev_timestamp' => $timestamp,
    -			'inverse_timestamp' => wfInvertTimestamp( $timestamp ),
     			'rev_minor_edit' => intval($minor) ),
     			$fname );
     		wfProfileOut( $fname );
    diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
    index 3d66a27735..f7d0e46e62 100644
    --- a/includes/GlobalFunctions.php
    +++ b/includes/GlobalFunctions.php
    @@ -962,8 +962,10 @@ function wfTimestampNow() {
     
     /**
      * Sorting hack for MySQL 3, which doesn't use index sorts for DESC
    + * No longer supported and nuked.
      */
     function wfInvertTimestamp( $ts ) {
    +	wfDieDebugBacktrace("Inverted timestamps should be nuked away from all code\n");
     	return strtr(
     		$ts,
     		'0123456789',
    diff --git a/includes/Image.php b/includes/Image.php
    index 56d5ddfdaa..de25a38103 100644
    --- a/includes/Image.php
    +++ b/includes/Image.php
    @@ -701,7 +701,6 @@ function wfRecordUpload( $name, $oldver, $size, $desc, $copyStatus = '', $source
     
     
     	$now = wfTimestampNow();
    -	$won = wfInvertTimestamp( $now );
     	$size = IntVal( $size );
     
     	if ( $wgUseCopyrightUpload ) {
    @@ -712,7 +711,6 @@ function wfRecordUpload( $name, $oldver, $size, $desc, $copyStatus = '', $source
     	else $textdesc = $desc ;
     
     	$now = wfTimestampNow();
    -	$won = wfInvertTimestamp( $now );
     
     	# Test to see if the row exists using INSERT IGNORE
     	# This avoids race conditions by locking the row until the commit, and also
    diff --git a/includes/PageHistory.php b/includes/PageHistory.php
    index cc0fdf4e80..744de137ff 100644
    --- a/includes/PageHistory.php
    +++ b/includes/PageHistory.php
    @@ -69,7 +69,7 @@ class PageHistory {
     		  "rev_comment,rev_user_text,rev_timestamp,rev_minor_edit ".
     		  "FROM $revision $use_index " .
     		  "WHERE rev_page=$id " .
    -		  "ORDER BY inverse_timestamp ".$db->limitResult($limitplus,$offset);
    +		  "ORDER BY rev_timestamp DESC ".$db->limitResult($limitplus,$offset);
     		$res = $db->query( $sql, $fname );
     
     		$revs = $db->numRows( $res );
    diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php
    index 94aa5f5589..bda7a3cb20 100644
    --- a/includes/SpecialContributions.php
    +++ b/includes/SpecialContributions.php
    @@ -104,7 +104,7 @@ function wfSpecialContributions( $par = '' ) {
     		rev_id,rev_timestamp,rev_comment,rev_minor_edit,rev_user_text
     		FROM $page,$revision $use_index
     		WHERE page_id=rev_page AND $condition $minorQuery " .
    -	  "ORDER BY inverse_timestamp LIMIT {$querylimit}";
    +	  "ORDER BY rev_timestamp DESC LIMIT {$querylimit}";
     	$res = $dbr->query( $sql, $fname );
     	$numRows = $dbr->numRows( $res );
     
    diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php
    index 0211a1a344..81435578bd 100644
    --- a/includes/SpecialImport.php
    +++ b/includes/SpecialImport.php
    @@ -503,7 +503,6 @@ class WikiImporter {
     				'old_user' => intval( $user->getId() ),
     				'old_user_text' => $user->getName(),
     				'old_timestamp' => $this->timestamp,
    -				'inverse_timestamp' => wfInvertTimestamp( $this->timestamp ),
     				'old_minor_edit' => 0,
     				'old_flags' => ''
     			), $fname
    diff --git a/includes/SpecialRecentchangeslinked.php b/includes/SpecialRecentchangeslinked.php
    index 343c3e95f4..37516fcb9e 100644
    --- a/includes/SpecialRecentchangeslinked.php
    +++ b/includes/SpecialRecentchangeslinked.php
    @@ -74,13 +74,13 @@ function wfSpecialRecentchangeslinked( $par = NULL ) {
     		  "rev_user_text,rev_timestamp,rev_minor_edit,page_is_new FROM $categorylinks, $revision, $page " .
     		  "WHERE rev_timestamp > '{$cutoff}' {$cmq} AND cl_from=page_id AND cl_to=$catkey " .
     			  "GROUP BY page_id,page_namespace,page_title,rev_user,rev_comment,rev_user_text," .
    -		  "rev_timestamp,rev_minor_edit,page_is_new,inverse_timestamp ORDER BY inverse_timestamp LIMIT {$limit}";
    +		  "rev_timestamp,rev_minor_edit,page_is_new ORDER BY rev_timestamp DESC LIMIT {$limit}";
     	} else {
     		$sql = "SELECT page_id,page_namespace,page_title,rev_user,rev_comment," .
     		  "rev_user_text,rev_timestamp,rev_minor_edit,page_is_new FROM $links, $revision, $page " .
     		  "WHERE rev_timestamp > '{$cutoff}' {$cmq} AND l_to=page_id AND l_from=$id " .
     			  "GROUP BY page_id,page_namespace,page_title,rev_user,rev_comment,rev_user_text," .
    -		  "rev_timestamp,rev_minor_edit,page_is_new,inverse_timestamp ORDER BY inverse_timestamp LIMIT {$limit}";
    +		  "rev_timestamp,rev_minor_edit,page_is_new ORDER BY rev_timestamp DESC LIMIT {$limit}";
     	}
     	$res = $dbr->query( $sql, $fname );
     
    diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php
    index 9d874d4f8f..616d5e8a3e 100644
    --- a/includes/SpecialUndelete.php
    +++ b/includes/SpecialUndelete.php
    @@ -184,7 +184,6 @@ class PageArchive {
     				'cur_is_redirect' => $redir,
     				'cur_random' => $rand,
     				'cur_touched' => $dbw->timestamp( $now ),
    -				'inverse_timestamp' => wfInvertTimestamp( wfTimestamp( TS_MW, $s->ar_timestamp ) ),
     			), $fname );
     			
     			$newid = $dbw->insertId();
    @@ -213,9 +212,9 @@ class PageArchive {
     			$oldones = "AND ar_timestamp IN ( {$oldts} )";
     		}
     		$sql = "INSERT INTO $old (old_namespace,old_title,old_text," .
    -		  "old_comment,old_user,old_user_text,old_timestamp,inverse_timestamp,old_minor_edit," .
    +		  "old_comment,old_user,old_user_text,old_timestamp,old_minor_edit," .
     		  "old_flags) SELECT ar_namespace,ar_title,ar_text,ar_comment," .
    -		  "ar_user,ar_user_text,ar_timestamp,99999999999999-ar_timestamp,ar_minor_edit,ar_flags " .
    +		  "ar_user,ar_user_text,ar_timestamp,ar_minor_edit,ar_flags " .
     		  "FROM $archive WHERE ar_namespace={$namespace} AND ar_title='{$t}' {$oldones}";
     		if( $restoreAll || !empty( $oldts ) ) {
     			$dbw->query( $sql, $fname );
    diff --git a/includes/Title.php b/includes/Title.php
    index 329a36255f..a9163a2fe9 100644
    --- a/includes/Title.php
    +++ b/includes/Title.php
    @@ -1442,7 +1442,6 @@ class Title {
     		$comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
     		
     		$now = wfTimestampNow();
    -		$won = wfInvertTimestamp( $now );
     		$rand = wfRandom();
     		$newid = $nt->getArticleID();
     		$oldid = $this->getArticleID();
    @@ -1474,8 +1473,8 @@ class Title {
     			'rev_comment' => $comment,
     			'rev_user' => $wgUser->getID(),
     			'rev_user_text' => $wgUser->getName(),
    -			'rev_timestamp' => $now,
    -			'inverse_timestamp' => $won ), $fname
    +			'rev_timestamp' => $now
    +			), $fname
     		);
     		$revid = $dbw->insertId();
     		$dbw->insert( 'text', array(
    @@ -1578,7 +1577,6 @@ class Title {
     		$oldid = $this->getArticleID();
     		$dbw =& wfGetDB( DB_MASTER );
     		$now = $dbw->timestamp();
    -		$won = wfInvertTimestamp( wfTimestamp(TS_MW,$now) );
     		wfSeedRandom();
     		$rand = wfRandom();
     
    @@ -1602,8 +1600,8 @@ class Title {
     			'rev_comment' => $comment,
     			'rev_user' => $wgUser->getID(),
     			'rev_user_text' => $wgUser->getName(),
    -			'rev_timestamp' => $now,
    -			'inverse_timestamp' => $won ), $fname
    +			'rev_timestamp' => $now
    +			), $fname
     		);
     		$revid = $dbw->insertId();
     		$dbw->insert( 'text', array(
    @@ -1728,7 +1726,6 @@ class Title {
     		$fname = 'Title::createRedirect';
     		$dbw =& wfGetDB( DB_MASTER );
     		$now = wfTimestampNow();
    -		$won = wfInvertTimestamp( $now );
     		
     		$seqVal = $dbw->nextSequenceValue( 'page_page_id_seq' );
     		$dbw->insert( 'page', array(
    @@ -1757,7 +1754,6 @@ class Title {
     			'rev_user' => $wgUser->getID(),
     			'rev_user_text' => $wgUser->getName(),
     			'rev_timestamp' => $now,
    -			'inverse_timestamp' => $won,
     		), $fname );
     		
     		$dbw->update( 'page',
    @@ -1913,4 +1909,4 @@ class Title {
     	}
     
     }
    -?>
    \ No newline at end of file
    +?>
    diff --git a/maintenance/InitialiseMessages.inc b/maintenance/InitialiseMessages.inc
    index cb821c0218..8fa5af3d2b 100755
    --- a/maintenance/InitialiseMessages.inc
    +++ b/maintenance/InitialiseMessages.inc
    @@ -197,8 +197,8 @@ function initialiseMessagesReal( $overwrite = false, $messageArray = false ) {
     			$page_id = $dbw->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, '{$username}', '{$timestamp}', '{$invTimestamp}', 0)";
    +							rev_timestamp, rev_minor_edit)
    +					VALUES ({$text_id}, {$page_id}, '', 0, '{$username}', '{$timestamp}', 0)";
     			$dbw->query( $sql, $fname );
     
     		}
    @@ -225,4 +225,4 @@ function doUpdates() {
     	global $wgDeferredUpdateList;
     	foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
     }
    -?>
    \ No newline at end of file
    +?>
    diff --git a/maintenance/archives/patch-restructure.sql b/maintenance/archives/patch-restructure.sql
    index 392b122830..5cdd9addef 100644
    --- a/maintenance/archives/patch-restructure.sql
    +++ b/maintenance/archives/patch-restructure.sql
    @@ -34,14 +34,13 @@ CREATE TABLE /*$wgDBprefix*/revision (
       rev_user_text varchar(255) binary NOT NULL default '',
       rev_timestamp char(14) binary NOT NULL default '',
       rev_minor_edit tinyint(1) unsigned NOT NULL default '0',
    -  inverse_timestamp char(14) binary NOT NULL default '',
       
       PRIMARY KEY rev_page_id (rev_page, rev_id),
       UNIQUE INDEX rev_id (rev_id),
       INDEX rev_timestamp (rev_timestamp),
    -  INDEX page_timestamp (rev_page,inverse_timestamp),
    -  INDEX user_timestamp (rev_user,inverse_timestamp),
    -  INDEX usertext_timestamp (rev_user_text,inverse_timestamp)
    +  INDEX page_timestamp (rev_page,rev_timestamp),
    +  INDEX user_timestamp (rev_user,rev_timestamp),
    +  INDEX usertext_timestamp (rev_user_text,rev_timestamp)
     );
     
     -- If creating new 'text' table it would look like this:
    @@ -72,8 +71,7 @@ INSERT
         old_user_text,
         old_timestamp,
         old_minor_edit,
    -    old_flags,
    -    inverse_timestamp)
    +    old_flags)
       SELECT
         cur_namespace,
         cur_title,
    @@ -83,8 +81,7 @@ INSERT
         cur_user_text,
         cur_timestamp,
         cur_minor_edit,
    -    '',
    -    inverse_timestamp
    +    ''
       FROM /*$wgDBprefix*/cur;
     
     -- Now, copy all old data except the text into revisions
    @@ -96,7 +93,6 @@ INSERT
         rev_user,
         rev_user_text,
         rev_timestamp,
    -    inverse_timestamp,
         rev_minor_edit)
       SELECT
         old_id,
    @@ -105,7 +101,6 @@ INSERT
         old_user,
         old_user_text,
         old_timestamp,
    -    old.inverse_timestamp,
         old_minor_edit
       FROM /*$wgDBprefix*/old,/*$wgDBprefix*/cur
       WHERE old_namespace=cur_namespace
    diff --git a/maintenance/importPhase2.php b/maintenance/importPhase2.php
    index 5d87475935..e53097b0f6 100644
    --- a/maintenance/importPhase2.php
    +++ b/maintenance/importPhase2.php
    @@ -109,10 +109,10 @@ class Phase2Importer {
     		print "Importing current revision data...\n";
     		wfQuery( "INSERT INTO cur (cur_id,cur_namespace,cur_title,cur_text,cur_comment,
     			cur_user,cur_user_text,cur_timestamp,cur_restrictions,cur_counter,
    -			cur_is_redirect,cur_minor_edit,cur_is_new,cur_random,cur_touched,inverse_timestamp)
    +			cur_is_redirect,cur_minor_edit,cur_is_new,cur_random,cur_touched)
     			SELECT cur_id,0,cur_title,cur_text,cur_comment,
     				cur_user,cur_user_text,cur_timestamp,REPLACE(cur_restrictions,'is_',''),cur_counter,
    -				cur_text like '#redirect%',cur_minor_edit,0,RAND(),NOW()+0,99999999999999-cur_timestamp
    +				cur_text like '#redirect%',cur_minor_edit,0,RAND(),NOW()+0,
     			FROM {$this->olddb}.cur", DB_MASTER );
     		$n = mysql_affected_rows();
     		print "$n rows imported.\n";
    @@ -124,9 +124,9 @@ class Phase2Importer {
     
     		print "Importing old revision data...\n";
     		wfQuery( "INSERT INTO old (old_id,old_namespace,old_title,old_text,old_comment,
    -			old_user,old_user_text,old_timestamp,old_minor_edit,old_flags,inverse_timestamp)
    +			old_user,old_user_text,old_timestamp,old_minor_edit,old_flags)
     			SELECT old_id,0,old_title,old_text,old_comment,
    -				old_user,old_user_text,old_timestamp,old_minor_edit,'',99999999999999-old_timestamp
    +				old_user,old_user_text,old_timestamp,old_minor_edit,''
     			FROM {$this->olddb}.old", DB_MASTER );
     		$n = mysql_affected_rows();
     		print "$n rows imported.\n";
    diff --git a/maintenance/importUseModWiki.php b/maintenance/importUseModWiki.php
    index 720e4ab8f3..8a23f8bc77 100644
    --- a/maintenance/importUseModWiki.php
    +++ b/maintenance/importUseModWiki.php
    @@ -243,7 +243,6 @@ function importPage( $title )
     		$timestamp = wfUnix2Timestamp( time() );
     		$redirect = ( preg_match( '/^#REDIRECT/', $page->text ) ? 1 : 0 );
     		$random = mt_rand() / mt_getrandmax();
    -		$inverse = wfInvertTimestamp( $timestamp );
     		
     		$revisions = array( $page );
     	} else {
    @@ -258,14 +257,13 @@ function importPage( $title )
     		$timestamp = wfUnix2Timestamp( $page->ts );
     		$redirect = ( preg_match( '/^#REDIRECT/', $page->text ) ? 1 : 0 );
     		$random = mt_rand() / mt_getrandmax();
    -		$inverse = wfInvertTimestamp( $timestamp );
     
     		$revisions = array();
     	}
     	$sql = "
     INSERT
    -	INTO cur (cur_namespace,cur_title,cur_text,cur_comment,cur_user,cur_user_text,cur_timestamp,inverse_timestamp,cur_touched,cur_minor_edit,cur_is_redirect,cur_random) VALUES
    -	($namespace,'$newtitle','$text','$comment',$userid,'$username','$timestamp','$inverse','$conversiontime',$minor,$redirect,$random);\n";
    +	INTO cur (cur_namespace,cur_title,cur_text,cur_comment,cur_user,cur_user_text,cur_timestamp,cur_touched,cur_minor_edit,cur_is_redirect,cur_random) VALUES
    +	($namespace,'$newtitle','$text','$comment',$userid,'$username','$timestamp','$conversiontime',$minor,$redirect,$random);\n";
     
     	# History
     	$revisions = array_merge( $revisions, fetchKeptPages( $title ) );
    @@ -275,18 +273,17 @@ INSERT
     	
     	$any = false;
     	$sql .= "INSERT
    -	INTO old (old_namespace,old_title,old_text,old_comment,old_user,old_user_text,old_timestamp,inverse_timestamp,old_minor_edit) VALUES\n";
    +	INTO old (old_namespace,old_title,old_text,old_comment,old_user,old_user_text,old_timestamp,old_minor_edit) VALUES\n";
     	foreach( $revisions as $rev ) {
     		$text = wfStrencode( recodeText( $rev->text ) );
     		$minor = ($rev->minor ? 1 : 0);
     		list( $userid, $username ) = checkUserCache( $rev->username, $rev->host );
     		$username = wfStrencode( recodeText( $username ) );
     		$timestamp = wfUnix2Timestamp( $rev->ts );
    -		$inverse = wfInvertTimestamp( $timestamp );
     		$comment = wfStrencode( recodeText( $rev->summary ) );
     		
     		if($any) $sql .= ",";
    -		$sql .= "\n\t($namespace,'$newtitle','$text','$comment',$userid,'$username','$timestamp','$inverse',$minor)";
    +		$sql .= "\n\t($namespace,'$newtitle','$text','$comment',$userid,'$username','$timestamp',$minor)";
     		$any = true;
     	}
     	$sql .= ";\n\n";
    diff --git a/maintenance/postgresql/pg_tables.sql b/maintenance/postgresql/pg_tables.sql
    index ca72133928..2e439f9fdb 100644
    --- a/maintenance/postgresql/pg_tables.sql
    +++ b/maintenance/postgresql/pg_tables.sql
    @@ -21,8 +21,7 @@ CREATE TABLE cur (
         cur_minor_edit smallint DEFAULT 0 NOT NULL,
         cur_is_new smallint DEFAULT 0 NOT NULL,
         cur_random double precision DEFAULT random(),
    -    cur_touched timestamp without time zone,
    -    inverse_timestamp varchar(14)
    +    cur_touched timestamp without time zone
     );
     CREATE INDEX cur_title_namespace_idx ON cur (cur_title, cur_namespace);
     CREATE INDEX cur_random_idx ON cur (cur_random);
    @@ -39,8 +38,7 @@ CREATE TABLE "old" (
         old_user_text varchar(255) NOT NULL,
         old_timestamp timestamp without time zone NOT NULL,
         old_minor_edit smallint NOT NULL,
    -    old_flags text NOT NULL,
    -    inverse_timestamp varchar(14) NOT NULL
    +    old_flags text NOT NULL
     );
     CREATE INDEX old_name_title_ts_idx ON "old" (old_namespace, old_title, old_timestamp);
     CREATE INDEX old_timestamp ON "old" (old_timestamp);
    diff --git a/maintenance/rebuildrecentchanges.inc b/maintenance/rebuildrecentchanges.inc
    index 13a8da0db4..888588fa57 100644
    --- a/maintenance/rebuildrecentchanges.inc
    +++ b/maintenance/rebuildrecentchanges.inc
    @@ -34,7 +34,7 @@ function rebuildRecentChangesTablePass1()
     			'rc_this_oldid' => 0,
     			'rc_last_oldid' => 0,
     			'rc_type' => $dbw->conditional( 'cur_is_new != 0', RC_NEW, RC_EDIT ),
    -		), '*', $fname, array( 'ORDER BY' => 'inverse_timestamp', 'LIMIT' => 5000 )
    +		), '*', $fname, array( 'ORDER BY' => 'cur_timestamp DESC', 'LIMIT' => 5000 )
     	);
     	
     	print( "Loading from OLD table...\n" );
    @@ -44,7 +44,7 @@ function rebuildRecentChangesTablePass1()
           "rc_cur_id,rc_this_oldid,rc_last_oldid,rc_type) SELECT old_timestamp,cur_timestamp," .
     	  "old_user,old_user_text,old_namespace,old_title,old_comment," .
     	  "old_minor_edit,0,0,cur_id,old_id,0,0 FROM $old,$cur " .
    -	  "WHERE old_namespace=cur_namespace AND old_title=cur_title ORDER BY $old.inverse_timestamp " .
    +	  "WHERE old_namespace=cur_namespace AND old_title=cur_title ORDER BY old_timestamp DESC " .
     	  "LIMIT 5000";
     	$dbw->query( $sql );
     
    @@ -83,10 +83,10 @@ function rebuildRecentChangesTablePass2()
     		if( $obj->rc_cur_id != $lastCurId ) {
     			# Switch! Look up the previous last edit, if any
     			$lastCurId = IntVal( $obj->rc_cur_id );
    -			$emit = wfInvertTimestamp( $obj->rc_timestamp );
    +			$emit = $obj->rc_timestamp;
     			$sql2 = "SELECT old_id FROM $old,$cur " .
     				"WHERE old_namespace=cur_namespace AND old_title=cur_title AND cur_id={$lastCurId} ".
    -				"AND $old.inverse_timestamp>'{$emit}' ORDER BY $old.inverse_timestamp LIMIT 1";
    +				"AND old_timestamp<'{$emit}' ORDER BY old_timestamp DESC LIMIT 1";
     			$res2 = $dbw->query( $sql2 );
     			if( $row = $dbw->fetchObject( $res2 ) ) {
     				$lastOldId = IntVal( $row->old_id );
    diff --git a/maintenance/tables.sql b/maintenance/tables.sql
    index 6e615bc3e1..0588b94220 100644
    --- a/maintenance/tables.sql
    +++ b/maintenance/tables.sql
    @@ -60,14 +60,13 @@ CREATE TABLE /*$wgDBprefix*/revision (
       rev_user_text varchar(255) binary NOT NULL default '',
       rev_timestamp char(14) binary NOT NULL default '',
       rev_minor_edit tinyint(1) unsigned NOT NULL default '0',
    -  inverse_timestamp char(14) binary NOT NULL default '',
       
       PRIMARY KEY rev_page_id (rev_page, rev_id),
       UNIQUE INDEX rev_id (rev_id),
       INDEX rev_timestamp (rev_timestamp),
    -  INDEX page_timestamp (rev_page,inverse_timestamp),
    -  INDEX user_timestamp (rev_user,inverse_timestamp),
    -  INDEX usertext_timestamp (rev_user_text,inverse_timestamp)
    +  INDEX page_timestamp (rev_page,rev_timestamp),
    +  INDEX user_timestamp (rev_user,rev_timestamp),
    +  INDEX usertext_timestamp (rev_user_text,rev_timestamp)
     );
     
     
    diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc
    index 4d0c9d5ea4..d2d326ce2a 100644
    --- a/maintenance/updaters.inc
    +++ b/maintenance/updaters.inc
    @@ -359,14 +359,13 @@ function do_schema_restructuring() {
       			rev_user_text varchar(255) binary NOT NULL default '',
       			rev_timestamp char(14) binary NOT NULL default '',
       			rev_minor_edit tinyint(1) unsigned NOT NULL default '0',
    -  			inverse_timestamp char(14) binary NOT NULL default '',
       
       			PRIMARY KEY rev_page_id (rev_page, rev_id),
       			UNIQUE INDEX rev_id (rev_id),
       			INDEX rev_timestamp (rev_timestamp),
    -  			INDEX page_timestamp (rev_page,inverse_timestamp),
    -  			INDEX user_timestamp (rev_user,inverse_timestamp),
    -  			INDEX usertext_timestamp (rev_user_text,inverse_timestamp)
    +  			INDEX page_timestamp (rev_page,rev_timestamp),
    +  			INDEX user_timestamp (rev_user,rev_timestamp),
    +  			INDEX usertext_timestamp (rev_user_text,rev_timestamp)
     			)", $fname );
     
     		echo "......Locking tables.\n";
    @@ -377,16 +376,15 @@ function do_schema_restructuring() {
     
     		echo "......Moving text from cur.\n";
     		$wgDatabase->query( "INSERT INTO $old (old_namespace, old_title, old_text, old_comment, old_user, old_user_text,
    -    				old_timestamp, old_minor_edit, old_flags, inverse_timestamp)
    -  			SELECT cur_namespace, cur_title, cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit,
    -    				'', inverse_timestamp
    +    				old_timestamp, old_minor_edit, old_flags, rev_timestamp)
    +  			SELECT cur_namespace, cur_title, cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit,''
       			FROM $cur", $fname );
     
     		echo "......Setting up revision table.\n";
     		$wgDatabase->query( "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, rev_timestamp,
    -    				inverse_timestamp, rev_minor_edit)
    +    				rev_minor_edit)
     			SELECT old_id, cur_id, old_comment, old_user, old_user_text,
    -    				old_timestamp, $old.inverse_timestamp, old_minor_edit
    +    				old_timestamp, old_minor_edit
     			FROM $old,$cur WHERE old_namespace=cur_namespace AND old_title=cur_title", $fname );
     
     		echo "......Setting up page table.\n";