r41198 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41197‎ | r41198 | r41199 >
Date:18:20, 23 September 2008
Author:aaron
Status:old
Tags:
Comment:
* Make Article::doEdit() return the revId, not just true/false. Make the article rollback stuff use this rather than 'next' to avoid slave usage for rollback diff. (bug 15672)
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -1421,7 +1421,7 @@
14221422 * to MediaWiki's performance-optimised locking strategy.
14231423 * @param $baseRevId, the revision ID this edit was based off, if any
14241424 *
1425 - * @return bool success
 1425+ * @return int Current revision ID after this edit
14261426 */
14271427 function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
14281428 global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries;
@@ -1522,6 +1522,7 @@
15231523 if( !$ok ) {
15241524 /* Belated edit conflict! Run away!! */
15251525 $good = false;
 1526+ $revisionId = 0;
15261527 $dbw->rollback();
15271528 } else {
15281529 wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, $baseRevId ) );
@@ -1621,7 +1622,7 @@
16221623 }
16231624
16241625 wfProfileOut( __METHOD__ );
1625 - return $good;
 1626+ return $revisionId;
16261627 }
16271628
16281629 /**
@@ -2474,7 +2475,7 @@
24752476
24762477 # Check permissions
24772478 $errors = array_merge( $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser ),
2478 - $this->mTitle->getUserPermissionsErrors( 'rollback', $wgUser ) );
 2479+ $this->mTitle->getUserPermissionsErrors( 'rollback', $wgUser ) );
24792480 if( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) )
24802481 $errors[] = array( 'sessionfailure' );
24812482
@@ -2578,12 +2579,13 @@
25792580 # Save
25802581 $flags = EDIT_UPDATE;
25812582
2582 - if ($wgUser->isAllowed('minoredit'))
 2583+ if( $wgUser->isAllowed('minoredit') )
25832584 $flags |= EDIT_MINOR;
25842585
25852586 if( $bot && ($wgUser->isAllowed('markbotedits') || $wgUser->isAllowed('bot')) )
25862587 $flags |= EDIT_FORCE_BOT;
2587 - $this->doEdit( $target->getText(), $summary, $flags, $target->getId() );
 2588+ # Actually store the edit
 2589+ $revId = $this->doEdit( $target->getText(), $summary, $flags, $target->getId() );
25882590
25892591 wfRunHooks( 'ArticleRollbackComplete', array( $this, $wgUser, $target ) );
25902592
@@ -2591,6 +2593,7 @@
25922594 'summary' => $summary,
25932595 'current' => $current,
25942596 'target' => $target,
 2597+ 'newid' => $revId
25952598 );
25962599 return array();
25972600 }
@@ -2618,7 +2621,7 @@
26192622 $wgOut->rateLimited();
26202623 return;
26212624 }
2622 - if( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ){
 2625+ if( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) {
26232626 $wgOut->setPageTitle( wfMsg( 'rollbackfailed' ) );
26242627 $errArray = $result[0];
26252628 $errMsg = array_shift( $errArray );
@@ -2626,7 +2629,8 @@
26272630 if( isset( $details['current'] ) ){
26282631 $current = $details['current'];
26292632 if( $current->getComment() != '' ) {
2630 - $wgOut->addWikiMsgArray( 'editcomment', array( $wgUser->getSkin()->formatComment( $current->getComment() ) ), array( 'replaceafter' ) );
 2633+ $wgOut->addWikiMsgArray( 'editcomment', array(
 2634+ $wgUser->getSkin()->formatComment( $current->getComment() ) ), array( 'replaceafter' ) );
26312635 }
26322636 }
26332637 return;
@@ -2653,6 +2657,7 @@
26542658
26552659 $current = $details['current'];
26562660 $target = $details['target'];
 2661+ $newId = $details['newid'];
26572662 $wgOut->setPageTitle( wfMsg( 'actioncomplete' ) );
26582663 $wgOut->setRobotPolicy( 'noindex,nofollow' );
26592664 $old = $wgUser->getSkin()->userLink( $current->getUser(), $current->getUserText() )
@@ -2663,7 +2668,7 @@
26642669 $wgOut->returnToMain( false, $this->mTitle );
26652670
26662671 if( !$wgRequest->getBool( 'hidediff', false ) ) {
2667 - $de = new DifferenceEngine( $this->mTitle, $current->getId(), 'next', false, true );
 2672+ $de = new DifferenceEngine( $this->mTitle, $current->getId(), $newId, false, true );
26682673 $de->showDiff( '', '' );
26692674 }
26702675 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r41244Re r41198: if you're going to break the interface, you may as well do it prop...tstarling10:15, 25 September 2008