* Move ArticleSave hook execution into Article insert/update functions,
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 23 Aug 2005 08:15:14 +0000 (08:15 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 23 Aug 2005 08:15:14 +0000 (08:15 +0000)
  so they get called on non-EditPage actions that use these functions
  to create or update pages.

RELEASE-NOTES
includes/Article.php
includes/EditPage.php

index 1a2d7ef..9a6c466 100644 (file)
@@ -45,6 +45,9 @@ Misc work going on.....
 * (bug 3218) Use proper quoting on history Compare Revisions button
 * (bug 3220) Fix escaping of block URLs in Recentchanges
 * (bug 3227) Fix SQL injection introduced in experimental code
+* Move ArticleSave hook execution into Article insert/update functions,
+  so they get called on non-EditPage actions that use these functions
+  to create or update pages.
 
 
 === Caveats ===
index 887393f..87bda1d 100644 (file)
@@ -1037,6 +1037,13 @@ class Article {
                $fname = 'Article::insertNewArticle';
                wfProfileIn( $fname );
 
+               if( !wfRunHooks( 'ArticleSave', array( &$this, &$wgUser, &$text,
+                       &$summary, &$isminor, &$watchthis, NULL ) ) ) {
+                       wfDebug( "$fname: ArticleSave hook aborted save!\n" );
+                       wfProfileOut( $fname );
+                       return false;
+               }
+               
                $this->mGoodAdjustment = $this->isCountable( $text );
                $this->mTotalAdjustment = 1;
 
@@ -1097,6 +1104,10 @@ class Article {
 
                $oldid = 0; # new article
                $this->showArticle( $text, wfMsg( 'newarticle' ), false, $isminor, $now, $summary, $oldid );
+
+               wfRunHooks( 'ArticleSaveComplete', array( &$this, &$wgUser, $text,
+                       $summary, $isminor,
+                       $watchthis, NULL ) );
                wfProfileOut( $fname );
        }
 
@@ -1205,6 +1216,14 @@ class Article {
                wfProfileIn( $fname );
                $good = true;
 
+               if( !wfRunHooks( 'ArticleSave', array( &$this, &$wgUser, &$text,
+                       &$summary, &$minor,
+                       &$watchthis, &$sectionanchor ) ) ) {
+                       wfDebug( "$fname: ArticleSave hook aborted save!\n" );
+                       wfProfileOut( $fname );
+                       return false;
+               }
+
                $isminor = ( $minor && $wgUser->isLoggedIn() );
                if ( $this->isRedirect( $text ) ) {
                        # Remove all content but redirect
@@ -1326,6 +1345,10 @@ class Article {
 
                        $this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $isminor, $now, $summary, $lastRevision );
                }
+               wfRunHooks( 'ArticleSaveComplete',
+                       array( &$this, &$wgUser, $text,
+                       $summary, $minor,
+                       $watchthis, $sectionanchor ) );
                wfProfileOut( $fname );
                return $good;
        }
index df6d3a2..13242a0 100644 (file)
@@ -485,17 +485,11 @@ class EditPage {
                                        wfProfileOut( $fname );
                                        return false;
                                }
-                       if (wfRunHooks('ArticleSave', array(&$this->mArticle, &$wgUser, &$this->textbox1,
-                               &$this->summary, &$this->minoredit, &$this->watchthis, NULL)))
-                       {                                       
-
-                               $isComment=($this->section=='new');
-                               $this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
-                                       $this->minoredit, $this->watchthis, false, $isComment);
-                               wfRunHooks('ArticleSaveComplete', array(&$this->mArticle, &$wgUser, $this->textbox1,
-                                       $this->summary, $this->minoredit,
-                                       $this->watchthis, NULL));
-                       }
+
+                       $isComment=($this->section=='new');
+                       $this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
+                               $this->minoredit, $this->watchthis, false, $isComment);
+                       
                        wfProfileOut( $fname );
                        return false;
                }
@@ -574,23 +568,13 @@ class EditPage {
                $this->textbox1 = $text;
                $this->section = '';
 
-               if (wfRunHooks('ArticleSave', array(&$this->mArticle, &$wgUser, &$text,
-                       &$this->summary, &$this->minoredit,
-                       &$this->watchthis, &$sectionanchor)))
-               {
-                       # update the article here
-                       if($this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
-                               $this->watchthis, '', $sectionanchor ))
-                       {
-                               wfRunHooks('ArticleSaveComplete',
-                                       array(&$this->mArticle, &$wgUser, $text,
-                                       $this->summary, $this->minoredit,
-                                       $this->watchthis, $sectionanchor));
-                               wfProfileOut( $fname );
-                               return false;
-                       } else {
-                               $this->isConflict = true;
-                       }
+               # update the article here
+               if( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
+                       $this->watchthis, '', $sectionanchor ) ) {
+                       wfProfileOut( $fname );
+                       return false;
+               } else {
+                       $this->isConflict = true;
                }
                wfProfileOut( $fname );
                return true;