Change entry point of SpecialPage
authorjeroendedauw <jeroendedauw@gmail.com>
Thu, 5 Jul 2012 20:47:15 +0000 (22:47 +0200)
committerjeroendedauw <jeroendedauw@gmail.com>
Thu, 5 Jul 2012 20:54:25 +0000 (22:54 +0200)
The old entry point is the execute method, which clearly is not meant to be an entry point,
as it's overloaded in most subclasses, making it impossible for the deriving classes to do anything
before or after (which for instance sucks big time in SpecialCachedPage).

Change-Id: I74c22a1dc3b1a9d062295d5fb709fb87577810ae

includes/SpecialPage.php
includes/SpecialPageFactory.php
includes/actions/RevisiondeleteAction.php

index 9e6717f..cbd7134 100644 (file)
@@ -589,15 +589,50 @@ class SpecialPage {
                $out->setPageTitle( $this->getDescription() );
        }
 
+       /**
+        * Entry point.
+        *
+        * @since 1.20
+        *
+        * @param $subPage string|null
+        */
+       public final function run( $subPage ) {
+               $this->beforeExecute( $subPage );
+               $this->execute( $subPage );
+               $this->afterExecute( $subPage );
+       }
+
+       /**
+        * Gets called before @see SpecialPage::execute.
+        *
+        * @since 1.20
+        *
+        * @param $subPage string|null
+        */
+       protected function beforeExecute( $subPage ) {
+               // No-op
+       }
+
+       /**
+        * Gets called after @see SpecialPage::execute.
+        *
+        * @since 1.20
+        *
+        * @param $subPage string|null
+        */
+       protected function afterExecute( $subPage ) {
+               // No-op
+       }
+
        /**
         * Default execute method
         * Checks user permissions, calls the function given in mFunction
         *
         * This must be overridden by subclasses; it will be made abstract in a future version
         *
-        * @param $par String subpage string, if one was specified
+        * @param $subPage string|null
         */
-       function execute( $par ) {
+       public function execute( $subPage ) {
                $this->setHeaders();
                $this->checkPermissions();
 
@@ -607,7 +642,7 @@ class SpecialPage {
                        require_once( $this->mFile );
                }
                $this->outputHeader();
-               call_user_func( $func, $par, $this );
+               call_user_func( $func, $subPage, $this );
        }
 
        /**
index 02b8d54..1d62e8b 100644 (file)
@@ -490,7 +490,7 @@ class SpecialPageFactory {
                // Execute special page
                $profName = 'Special:' . $page->getName();
                wfProfileIn( $profName );
-               $page->execute( $par );
+               $page->run( $par );
                wfProfileOut( $profName );
                wfProfileOut( __METHOD__ );
                return true;
index f07e493..14da2fc 100644 (file)
@@ -44,6 +44,6 @@ class RevisiondeleteAction extends FormlessAction {
        public function show() {
                $special = SpecialPageFactory::getPage( 'Revisiondelete' );
                $special->setContext( $this->getContext() );
-               $special->execute( '' );
+               $special->run( '' );
        }
 }