*Redo newRevisionFromEditComplete hook. Pass an Article instead of a title
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 22 May 2008 01:03:45 +0000 (01:03 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 22 May 2008 01:03:45 +0000 (01:03 +0000)
*Use prepareTextForEdit() to avoid double parsing
*Parser cache will be saved again later, so need to do it twice in a row

docs/hooks.txt
includes/Article.php
includes/SpecialImport.php
includes/Title.php
includes/filerepo/ICRepo.php
includes/filerepo/LocalFile.php

index 03dfd42..576a79b 100644 (file)
@@ -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
 
index eaabb83..dedf4e7 100644 (file)
@@ -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__ );
        }
index a8e2311..862b3e1 100644 (file)
@@ -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( '<li>' . wfMsgHtml( 'import-nonewrevisions' ) . '</li>' );
                }
index 2752e0f..b8b5e1e 100644 (file)
@@ -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',
index a6980db..4c77ecb 100644 (file)
@@ -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
index 3751999..9e8a3ef 100644 (file)
@@ -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