From: jeroendedauw Date: Thu, 5 Jul 2012 20:47:15 +0000 (+0200) Subject: Change entry point of SpecialPage X-Git-Tag: 1.31.0-rc.0~23126 X-Git-Url: http://git.cyclocoop.org/data/%24self?a=commitdiff_plain;h=e773eb0af58715e8c35667e276c9ab2d6fa5a1ab;p=lhc%2Fweb%2Fwiklou.git Change entry point of SpecialPage 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 --- diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 9e6717fa50..cbd7134dd3 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -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 ); } /** diff --git a/includes/SpecialPageFactory.php b/includes/SpecialPageFactory.php index 02b8d54909..1d62e8b754 100644 --- a/includes/SpecialPageFactory.php +++ b/includes/SpecialPageFactory.php @@ -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; diff --git a/includes/actions/RevisiondeleteAction.php b/includes/actions/RevisiondeleteAction.php index f07e493d9c..14da2fcfec 100644 --- a/includes/actions/RevisiondeleteAction.php +++ b/includes/actions/RevisiondeleteAction.php @@ -44,6 +44,6 @@ class RevisiondeleteAction extends FormlessAction { public function show() { $special = SpecialPageFactory::getPage( 'Revisiondelete' ); $special->setContext( $this->getContext() ); - $special->execute( '' ); + $special->run( '' ); } }