From: Aaron Schulz Date: Thu, 22 May 2008 01:03:45 +0000 (+0000) Subject: *Redo newRevisionFromEditComplete hook. Pass an Article instead of a title X-Git-Tag: 1.31.0-rc.0~47480 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=9717cebd8844dfbe2b7d51b6eb71c60e4298723c;p=lhc%2Fweb%2Fwiklou.git *Redo newRevisionFromEditComplete hook. Pass an Article instead of a title *Use prepareTextForEdit() to avoid double parsing *Parser cache will be saved again later, so need to do it twice in a row --- diff --git a/docs/hooks.txt b/docs/hooks.txt index 03dfd425a4..576a79b25d 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -800,8 +800,8 @@ for all 'SkinTemplate'-type skins, use the SkinTemplateToolboxEnd hook instead. $tools: array of tools -'newRevisionFromEditComplete': called when a revision was inserted due to an edit -$title: the page title +'NewRevisionFromEditComplete': called when a revision was inserted due to an edit +$article: the page title $rev: the new revision $baseID: the revision ID this was based off, if any diff --git a/includes/Article.php b/includes/Article.php index eaabb83a42..dedf4e76cd 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1451,7 +1451,7 @@ class Article { # Update page $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision ); - wfRunHooks( 'newRevisionFromEditComplete', array($this->mTitle, $revision, $baseRevId) ); + wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId) ); if( !$ok ) { /* Belated edit conflict! Run away!! */ @@ -1523,7 +1523,7 @@ class Article { # Update the page record with revision data $this->updateRevisionOn( $dbw, $revision, 0 ); - wfRunHooks( 'newRevisionFromEditComplete', array($this->mTitle, $revision, false) ); + wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) ); if( !( $flags & EDIT_SUPPRESS_RC ) ) { $rcid = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, $bot, @@ -1883,7 +1883,7 @@ class Article { ), 'Article::protect' ); - wfRunHooks( 'newRevisionFromEditComplete', array($this->mTitle, $nullRevision, false) ); + wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, false) ); wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) ); # Update the protection log @@ -2978,7 +2978,7 @@ class Article { $this->updateRevisionOn( $dbw, $revision ); $dbw->commit(); - wfRunHooks( 'newRevisionFromEditComplete', array($this->mTitle, $revision, false) ); + wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) ); wfProfileOut( __METHOD__ ); } diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php index a8e23113c8..862b3e1861 100644 --- a/includes/SpecialImport.php +++ b/includes/SpecialImport.php @@ -219,10 +219,10 @@ class ImportReporter { $dbw = wfGetDB( DB_MASTER ); $nullRevision = Revision::newNullRevision( $dbw, $title->getArticleId(), $comment, true ); $nullRevision->insertOn( $dbw ); - wfRunHooks( 'newRevisionFromEditComplete', array($title, $nullRevision, false) ); - # Update page record $article = new Article( $title ); + # Update page record $article->updateRevisionOn( $dbw, $nullRevision ); + wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, false) ); } else { $wgOut->addHtml( '
  • ' . wfMsgHtml( 'import-nonewrevisions' ) . '
  • ' ); } diff --git a/includes/Title.php b/includes/Title.php index 2752e0fae6..b8b5e1e56b 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2599,7 +2599,8 @@ class Title { # Save a null revision in the page's history notifying of the move $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true ); $nullRevId = $nullRevision->insertOn( $dbw ); - wfRunHooks( 'newRevisionFromEditComplete', array($nt, $nullRevision, false) ); + + $article = new Article( $nt ); # Change the name of the target page: $dbw->update( 'page', @@ -2613,6 +2614,8 @@ class Title { $fname ); $nt->resetArticleID( $oldid ); + + wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, false) ); # Recreate the redirect, this time in the other direction. if($createRedirect || !$wgUser->isAllowed('suppressredirect')) @@ -2626,8 +2629,9 @@ class Title { 'comment' => $comment, 'text' => $redirectText ) ); $redirectRevision->insertOn( $dbw ); - wfRunHooks( 'newRevisionFromEditComplete', array($this, $redirectRevision, false) ); $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); + + wfRunHooks( 'NewRevisionFromEditComplete', array($redirectArticle, $redirectRevision, false) ); # Now, we record the link from the redirect to the new title. # It should have no other outgoing links... @@ -2688,7 +2692,8 @@ class Title { # Save a null revision in the page's history notifying of the move $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true ); $nullRevId = $nullRevision->insertOn( $dbw ); - wfRunHooks( 'newRevisionFromEditComplete', array($nt, $nullRevision, false) ); + + $article = new Article( $nt ); # Rename page entry $dbw->update( 'page', @@ -2702,6 +2707,8 @@ class Title { $fname ); $nt->resetArticleID( $oldid ); + + wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, false) ); if($createRedirect || !$wgUser->isAllowed('suppressredirect')) { @@ -2715,8 +2722,9 @@ class Title { 'comment' => $comment, 'text' => $redirectText ) ); $redirectRevision->insertOn( $dbw ); - wfRunHooks( 'newRevisionFromEditComplete', array($this, $redirectRevision, false) ); $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); + + wfRunHooks( 'NewRevisionFromEditComplete', array($redirectArticle, $redirectRevision, false) ); # Record the just-created redirect's linking to the page $dbw->insert( 'pagelinks', diff --git a/includes/filerepo/ICRepo.php b/includes/filerepo/ICRepo.php index a6980db506..4c77ecbf3d 100644 --- a/includes/filerepo/ICRepo.php +++ b/includes/filerepo/ICRepo.php @@ -286,7 +286,9 @@ class ICFile extends LocalFile{ # Create a null revision $nullRevision = Revision::newNullRevision( $dbw, $descTitle->getArticleId(), $log->getRcComment(), false ); $nullRevision->insertOn( $dbw ); - wfRunHooks( 'newRevisionFromEditComplete', array($descTitle, $nullRevision, false) ); + + wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, false) ); + $article->updateRevisionOn( $dbw, $nullRevision ); # Invalidate the cache for the description page diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index 3751999817..9e8a3ef08e 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -879,7 +879,8 @@ class LocalFile extends File # Create a null revision $nullRevision = Revision::newNullRevision( $dbw, $descTitle->getArticleId(), $log->getRcComment(), false ); $nullRevision->insertOn( $dbw ); - wfRunHooks( 'newRevisionFromEditComplete', array($descTitle, $nullRevision, false) ); + + wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, false) ); $article->updateRevisionOn( $dbw, $nullRevision ); # Invalidate the cache for the description page