Improve efficiency of autoreviewing of edits rollbacks and merge into main function
authorAaron Schulz <aaron@users.mediawiki.org>
Fri, 16 May 2008 18:22:31 +0000 (18:22 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Fri, 16 May 2008 18:22:31 +0000 (18:22 +0000)
docs/hooks.txt
includes/Article.php
includes/Revision.php

index 22125c5..b0720bc 100644 (file)
@@ -920,6 +920,7 @@ $user: the User object to load preferences from
 'RevisionInsertComplete': called after a revision is inserted into the DB
 $revision: the Revision
 $edit: was this a new edit?
+$baseID: what revision ID was this revision based off? (false if none)
 
 'SavePreferences': called at the end of PreferencesForm::savePreferences; 
                    returning false prevents the preferences from being saved.
index fa2c58f..3192009 100644 (file)
@@ -1362,10 +1362,11 @@ class Article {
         * EDIT_NEW is specified and the article does exist, a duplicate key error will cause an exception
         * to be thrown from the Database. These two conditions are also possible with auto-detection due
         * to MediaWiki's performance-optimised locking strategy.
+        * @param integer $baseRevID, the revision ID this is based off
         *
         * @return bool success
         */
-       function doEdit( $text, $summary, $flags = 0 ) {
+       function doEdit( $text, $summary, $flags = 0, $baseRevID = false ) {
                global $wgUser, $wgDBtransactions;
 
                wfProfileIn( __METHOD__ );
@@ -1444,7 +1445,7 @@ class Article {
                                        ) );
 
                                $dbw->begin();
-                               $revisionId = $revision->insertOn( $dbw, true );
+                               $revisionId = $revision->insertOn( $dbw, true, $baseRevID );
 
                                # Update page
                                $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision );
@@ -2524,7 +2525,7 @@ class Article {
 
                if( $bot && ($wgUser->isAllowed('markbotedits') || $wgUser->isAllowed('bot')) )
                        $flags |= EDIT_FORCE_BOT;
-               $this->doEdit( $target->getText(), $summary, $flags );
+               $this->doEdit( $target->getText(), $summary, $flags, $target->getId() );
 
                wfRunHooks( 'ArticleRollbackComplete', array( $this, $wgUser, $target ) );
 
index 5d79167..050db2b 100644 (file)
@@ -708,9 +708,10 @@ class Revision {
         *
         * @param Database $dbw
         * @param bool $edit, was this a new edit? (optional)
+        * @param integer $baseID, what revision was this based on? (optional)
         * @return int
         */
-       public function insertOn( &$dbw, $edit=false ) {
+       public function insertOn( &$dbw, $edit = false, $baseID = false ) {
                global $wgDefaultExternalStore;
 
                wfProfileIn( __METHOD__ );
@@ -773,7 +774,7 @@ class Revision {
 
                $this->mId = !is_null($rev_id) ? $rev_id : $dbw->insertId();
                
-               wfRunHooks( 'RevisionInsertComplete', array( &$this, $edit ) );
+               wfRunHooks( 'RevisionInsertComplete', array( &$this, $edit, $baseID ) );
                
                wfProfileOut( __METHOD__ );
                return $this->mId;