From 21bc5be1a75c93c8358e9d86c23a833a050f5b2a Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 16 May 2008 18:22:31 +0000 Subject: [PATCH] Improve efficiency of autoreviewing of edits rollbacks and merge into main function --- docs/hooks.txt | 1 + includes/Article.php | 7 ++++--- includes/Revision.php | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 22125c528a..b0720bcd7e 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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. diff --git a/includes/Article.php b/includes/Article.php index fa2c58fe98..3192009f6f 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 ) ); diff --git a/includes/Revision.php b/includes/Revision.php index 5d791677f0..050db2b86f 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -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; -- 2.20.1