*Add ArticleUpdateBeforeRedirect hook, to allow for the page to redirect out differen...
authorAaron Schulz <aaron@users.mediawiki.org>
Wed, 15 Aug 2007 22:13:03 +0000 (22:13 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Wed, 15 Aug 2007 22:13:03 +0000 (22:13 +0000)
*Document ArticleUpdateBeforeRedirect hook

docs/hooks.txt
includes/Article.php

index b33a951..a22867e 100644 (file)
@@ -332,6 +332,10 @@ $create: Whether or not the restoration caused the page to be created
 &$pcache: whether to try the parser cache or not
 &$outputDone: whether the output for this page finished or not
 
+'ArticleUpdateBeforeRedirect': After a page is updated (usually on save), before the user is redirected back to the page
+&$article: the article
+&$extraq: Extra query parameters which can be added via hooked functions
+
 'AuthPluginSetup': update or replace authentication plugin object ($wgAuth)
 Gives a chance for an extension to set it programattically to a variable class.
 &$auth: the $wgAuth object, probably a stub
index 56feb72..10a714b 100644 (file)
@@ -1250,7 +1250,10 @@ class Article {
                                }
                        }
 
-                       $this->doRedirect( $this->isRedirect( $text ), $sectionanchor );
+                       $extraq = ''; // Give extensions a chance to modify URL query on update
+                       wfRunHooks( 'ArticleUpdateBeforeRedirect', array($this,&$extraq) );
+
+                       $this->doRedirect( $this->isRedirect( $text ), $sectionanchor, $extraq );
                }
                return $good;
        }
@@ -1486,12 +1489,14 @@ class Article {
         * @param boolean $noRedir Add redirect=no
         * @param string $sectionAnchor section to redirect to, including "#"
         */
-       function doRedirect( $noRedir = false, $sectionAnchor = '' ) {
+       function doRedirect( $noRedir = false, $sectionAnchor = '', $extraq = '' ) {
                global $wgOut;
                if ( $noRedir ) {
                        $query = 'redirect=no';
+                       if( $extraq )
+                               $query .= "&$query";
                } else {
-                       $query = '';
+                       $query = $extraq;
                }
                $wgOut->redirect( $this->mTitle->getFullURL( $query ) . $sectionAnchor );
        }