https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103383

Revision: 103383
Author:   ialex
Date:     2011-11-16 21:03:06 +0000 (Wed, 16 Nov 2011)
Log Message:
-----------
* Put the LinkCache update in WikiPage::updateRevisionOn() so that we are sure 
that it is executed every time that function get called (and the update 
succeeds of course); and removed the call to Title::resetArticleID() which is 
already done by insertOn()
* Also update $this->mLatest and $this->mIsRedirect in updateRevisionOn() (will 
use this in ApiEditPage to have to create another istance just to grab the new 
revision ID)
* In WikiPage::doEdit(), get the current latest before going through the 
process since it's now updated in updateRevisionOn() (would break 
RecentChange::notifyEdit() otherwise) and pass the current redirect state to 
use the optimisation in updateRedirectOn() if possible

Modified Paths:
--------------
    trunk/phase3/includes/WikiPage.php

Modified: trunk/phase3/includes/WikiPage.php
===================================================================
--- trunk/phase3/includes/WikiPage.php  2011-11-16 21:00:54 UTC (rev 103382)
+++ trunk/phase3/includes/WikiPage.php  2011-11-16 21:03:06 UTC (rev 103383)
@@ -815,6 +815,7 @@
                wfProfileIn( __METHOD__ );
 
                $text = $revision->getText();
+               $len = strlen( $text );
                $rt = Title::newFromRedirectRecurse( $text );
 
                $conditions = array( 'page_id' => $this->getId() );
@@ -831,7 +832,7 @@
                                'page_touched'     => $dbw->timestamp( $now ),
                                'page_is_new'      => ( $lastRevision === 0 ) ? 
1 : 0,
                                'page_is_redirect' => $rt !== null ? 1 : 0,
-                               'page_len'         => strlen( $text ),
+                               'page_len'         => $len,
                        ),
                        $conditions,
                        __METHOD__ );
@@ -839,7 +840,12 @@
                $result = $dbw->affectedRows() != 0;
                if ( $result ) {
                        $this->updateRedirectOn( $dbw, $rt, $lastRevIsRedirect 
);
+                       $this->setLastEdit( $revision );
                        $this->setCachedLastEditTime( $now );
+                       $this->mLatest = $revision->getId();
+                       $this->mIsRedirect = (bool)$rt;
+                       # Update the LinkCache.
+                       LinkCache::singleton()->addGoodLinkObj( $this->getId(), 
$this->mTitle, $len, $this->mIsRedirect, $this->mLatest );
                }
 
                wfProfileOut( __METHOD__ );
@@ -1094,6 +1100,8 @@
 
                $oldtext = $this->getRawText(); // current revision
                $oldsize = strlen( $oldtext );
+               $oldid = $this->getLatest();
+               $oldIsRedirect = $this->isRedirect();
                $oldcountable = $this->isCountable();
 
                # Provide autosummaries if one is not provided and 
autosummaries are enabled.
@@ -1123,7 +1131,7 @@
                                'comment'    => $summary,
                                'minor_edit' => $isminor,
                                'text'       => $text,
-                               'parent_id'  => $this->mLatest,
+                               'parent_id'  => $oldid,
                                'user'       => $user->getId(),
                                'user_text'  => $user->getName(),
                                'timestamp'  => $now
@@ -1151,7 +1159,7 @@
                                # edit conflicts reliably, either by $ok here, 
or by $article->getTimestamp()
                                # before this function is called. A previous 
function used a separate query, this
                                # creates a window where concurrent edits can 
cause an ignored edit conflict.
-                               $ok = $this->updateRevisionOn( $dbw, $revision, 
$this->mLatest );
+                               $ok = $this->updateRevisionOn( $dbw, $revision, 
$oldid, $oldIsRedirect );
 
                                if ( !$ok ) {
                                        /* Belated edit conflict! Run away!! */
@@ -1174,7 +1182,7 @@
                                                        
$this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
                                                # Add RC row to the DB
                                                $rc = RecentChange::notifyEdit( 
$now, $this->mTitle, $isminor, $user, $summary,
-                                                       $this->mLatest, 
$this->getTimestamp(), $bot, '', $oldsize, $newsize,
+                                                       $oldid, 
$this->getTimestamp(), $bot, '', $oldsize, $newsize,
                                                        $revisionId, $patrolled
                                                );
 
@@ -1241,11 +1249,6 @@
                        ) );
                        $revisionId = $revision->insertOn( $dbw );
 
-                       $this->mTitle->resetArticleID( $newid );
-                       # Update the LinkCache. Resetting the Title ArticleID 
means it will rely on having that already cached
-                       # @todo FIXME?
-                       LinkCache::singleton()->addGoodLinkObj( $newid, 
$this->mTitle, strlen( $text ), (bool)Title::newFromRedirect( $text ), 
$revisionId );
-
                        # Update the page record with revision data
                        $this->updateRevisionOn( $dbw, $revision, 0 );
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to