r41548 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41547‎ | r41548 | r41549 >
Date:17:30, 2 October 2008
Author:btongminh
Status:old (Comments)
Tags:
Comment:
Classes derived from SpecialPage can now specify a run() method, which will be executed after all magic performed by SpecialPage::execute().
Just because copying code to subclasses is annoying.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPage.php
@@ -740,8 +740,13 @@
741741 if ( $this->userCanExecute( $wgUser ) ) {
742742 $func = $this->mFunction;
743743 // only load file if the function does not exist
744 - if(!is_callable($func) and $this->mFile) {
745 - require_once( $this->mFile );
 744+ if ( !is_callable( $func ) ) {
 745+ // Check whether a run method has been defined
 746+ if ( is_callable( array( $this, 'run' ) ) )
 747+ $func = array( $this, 'run' );
 748+ // Else load from file if it has been specified
 749+ elseif ( $this->mFile )
 750+ require_once( $this->mFile );
746751 }
747752 # FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage.
748753 if ( wfRunHooks( 'SpecialPageExecuteBeforeHeader', array( &$this, &$par, &$func ) ) )
@@ -756,6 +761,7 @@
757762 }
758763 }
759764
 765+
760766 function outputHeader() {
761767 global $wgOut, $wgContLang;
762768
Index: trunk/phase3/RELEASE-NOTES
@@ -145,6 +145,8 @@
146146 $wgExternalLinkTarget
147147 * api.php now sends "Retry-After" and "X-Database-Lag" HTTP headers if the maxlag
148148 check fails, just like index.php does
 149+* Classes derived from SpecialPage can now specify a run() method, which will
 150+ be executed after all magic performed by SpecialPage::execute()
149151
150152
151153 === Bug fixes in 1.14 ===

Follow-up revisions

RevisionCommit summaryAuthorDate
r41584Back out r41548 "Classes derived from SpecialPage can now specify a run() met...brion00:38, 3 October 2008

Comments

#Comment by Simetrical (talk | contribs)   23:49, 2 October 2008

What do you actually plan to use this in? Generally speaking it's usually bad form to add new interfaces without adding anything that uses them. It doesn't let anyone see what it's meant to do, or if it's broken. What code copying would this avoid? In particular, if this is just to allow code to be executed after execute(), what's wrong with

function execute( $par ) { parent::execute( $par ); doMoreStuff(); }

#Comment by Brion VIBBER (talk | contribs)   00:38, 3 October 2008

Yeah, seems a little odd to me...

Backing out in r41584

Status & tagging log