Merge "Allow SpecialPage::beforeExecute to prevent execution"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 1 Apr 2016 14:58:49 +0000 (14:58 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 1 Apr 2016 14:58:49 +0000 (14:58 +0000)
docs/hooks.txt
includes/specialpage/SpecialPage.php

index 9478f48..01fae5b 100644 (file)
@@ -2855,6 +2855,7 @@ $special: the SpecialPage object
 $subPage: the subpage string or null if no subpage was specified
 
 'SpecialPageBeforeExecute': Called before SpecialPage::execute.
+Return false to prevent execution.
 $special: the SpecialPage object
 $subPage: the subpage string or null if no subpage was specified
 
index 6a04c6a..90ace7b 100644 (file)
@@ -395,15 +395,20 @@ class SpecialPage {
        final public function run( $subPage ) {
                /**
                 * Gets called before @see SpecialPage::execute.
+                * Return false to prevent calling execute() (since 1.27+).
                 *
                 * @since 1.20
                 *
                 * @param SpecialPage $this
                 * @param string|null $subPage
                 */
-               Hooks::run( 'SpecialPageBeforeExecute', [ $this, $subPage ] );
+               if ( !Hooks::run( 'SpecialPageBeforeExecute', [ $this, $subPage ] ) ) {
+                       return;
+               }
 
-               $this->beforeExecute( $subPage );
+               if ( $this->beforeExecute( $subPage ) === false ) {
+                       return;
+               }
                $this->execute( $subPage );
                $this->afterExecute( $subPage );
 
@@ -420,10 +425,12 @@ class SpecialPage {
 
        /**
         * Gets called before @see SpecialPage::execute.
+        * Return false to prevent calling execute() (since 1.27+).
         *
         * @since 1.20
         *
         * @param string|null $subPage
+        * @return bool|void
         */
        protected function beforeExecute( $subPage ) {
                // No-op