function &getOldContentFields() {
global $wgArticleOldContentFields;
if ( !$wgArticleOldContentFields ) {
- $wgArticleOldContentFields = array( 'old_articleid','old_text','old_timestamp',
+ $wgArticleOldContentFields = array( 'old_namespace','old_title','old_text','old_timestamp',
'old_user','old_user_text','old_comment','old_flags' );
}
return $wgArticleOldContentFields;
return;
}
- if( $this->mTitle->getArticleID() != $s->old_articleid ) {
- $oldTitle = Title::newFromID( $s->old_articleid );
+ 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;
}
$dbr =& $this->getDB();
$oldTable = $dbr->tableName( 'old' );
$userTable = $dbr->tableName( 'user' );
- $artid = $title->getArticleID();
+ $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_articleid = $artid
+ WHERE old_namespace = $user
+ AND old_title = $encDBkey
AND old_user != $user
GROUP BY old_user, old_user_text, user_real_name
ORDER BY timestamp DESC";
$dbw =& wfGetDB( DB_MASTER );
$ns = $this->mTitle->getNamespace();
$title = $this->mTitle->getDBkey();
- $aid = $this->mTitle->getArticleID();
$obj = $dbw->getArray( 'old',
array( 'old_text','old_flags'),
- array( 'old_articleid' => $aid,
+ array( 'old_namespace' => $ns, 'old_title' => $title,
'old_timestamp' => $dbw->timestamp($edittime)),
$fname );
$oldtext = Article::getRevisionText( $obj );
$dbw->insertArray( 'old',
array(
'old_id' => $dbw->nextSequenceValue( 'old_old_id_seq' ),
- 'old_articleid' => $this->mTitle->getArticleID(),
+ 'old_namespace' => $this->mTitle->getNamespace(),
+ 'old_title' => $this->mTitle->getDBkey(),
'old_text' => $oldtext,
'old_comment' => $this->getComment(),
'old_user' => $this->getUser(),
$dbr =& $this->getDB();
$ns = $this->mTitle->getNamespace();
$title = $this->mTitle->getDBkey();
- $artid = $this->mTitle->getArticleID();
$old = $dbr->getArray( 'old',
array( 'old_text', 'old_flags' ),
- array( 'old_articleid' => $artid ),
- $fname, $this->getSelectOptions( array( 'ORDER BY' => 'inverse_timestamp' ) )
+ array(
+ 'old_namespace' => $ns,
+ 'old_title' => $title,
+ ), $fname, $this->getSelectOptions( array( 'ORDER BY' => 'inverse_timestamp' ) )
);
if( $old !== false && !$confirm ) {
$recentchangesTable = $dbw->tableName( 'recentchanges' );
$linksTable = $dbw->tableName( 'links' );
$brokenlinksTable = $dbw->tableName( 'brokenlinks' );
- $artid = $this->mTitle->getArticleID();
$dbw->insertSelect( 'archive', 'cur',
array(
), $fname
);
- $dbw->insertSelect( 'archive', 'cur,old',
+ $dbw->insertSelect( 'archive', 'old',
array(
- 'ar_namespace' => 'cur_namespace',
- 'ar_title' => 'cur_title',
+ 'ar_namespace' => 'old_namespace',
+ 'ar_title' => 'old_title',
'ar_text' => 'old_text',
'ar_comment' => 'old_comment',
'ar_user' => 'old_user',
'ar_minor_edit' => 'old_minor_edit',
'ar_flags' => 'old_flags'
), array(
- 'old_articleid' => $artid
+ 'old_namespace' => $ns,
+ 'old_title' => $t,
), $fname
);
# Now that it's safely backed up, delete it
$dbw->delete( 'cur', array( 'cur_namespace' => $ns, 'cur_title' => $t ), $fname );
- $dbw->delete( 'old', array( 'old_articleid' => $artid ), $fname );
+ $dbw->delete( 'old', array( 'old_namespace' => $ns, 'old_title' => $t ), $fname );
$dbw->delete( 'recentchanges', array( 'rc_namespace' => $ns, 'rc_title' => $t ), $fname );
# Finally, clean up the link tables
$s = $dbw->getArray( 'old',
array( 'old_text','old_user','old_user_text','old_timestamp','old_flags' ),
array(
- 'old_articleid' => $pid,
+ 'old_namespace' => $n,
+ 'old_title' => $tt,
"old_user <> {$uid} OR old_user_text <> '{$ut}'"
- ), $fname, array( 'FOR UPDATE', 'USE INDEX' => 'articleid_timestamp' )
+ ), $fname, array( 'FOR UPDATE', 'USE INDEX' => 'name_title_timestamp' )
);
if( $s === false ) {
# Something wrong
# Save to history
$dbw->insertSelect( 'old', 'cur',
array(
- 'old_articleid' => 'cur_id',
+ 'old_namespace' => 'cur_namespace',
+ 'old_title' => 'cur_title',
'old_text' => 'cur_text',
'old_comment' => 'cur_comment',
'old_user' => 'cur_user',
$basenamespace = $wgTitle->getNamespace() & (~1);
$cur_clause = array( 'cur_title' => $wgTitle->getDBkey(), 'cur_namespace' => $basenamespace );
- $old_clause = array( 'old_articleid' => $wgTitle->getArticleID() );
+ $old_clause = array( 'old_title' => $wgTitle->getDBkey(), 'old_namespace' => $basenamespace );
$wl_clause = array( 'wl_title' => $wgTitle->getDBkey(), 'wl_namespace' => $basenamespace );
$fullTitle = $wgTitle->makeName($basenamespace, $wgTitle->getDBKey());
$wgOut->setPagetitle( $fullTitle );
# now for the Talk page ...
$cur_clause = array( 'cur_title' => $wgTitle->getDBkey(), 'cur_namespace' => $basenamespace+1 );
+ $old_clause = array( 'old_title' => $wgTitle->getDBkey(), 'old_namespace' => $basenamespace+1 );
# does it exist?
$exists = $dbr->selectField( 'cur', 'COUNT(*)', $cur_clause, $fname, $this->getSelectOptions() );
# number of edits
if ($exists > 0) {
- $oldartid = $dbr->selectField( 'cur', 'cur_id',
- $cur_clause, $fname, $this->getSelectOptions());
- $old_clause = array( 'old_articleid' => $oldartid );
$old = $dbr->selectField( 'old', 'COUNT(*)', $old_clause, $fname, $this->getSelectOptions() );
$wgOut->addHTML( '<li>' . wfMsg("numtalkedits", $old + 1) . '</li>');
}