r50129 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50128‎ | r50129 | r50130 >
Date:14:23, 2 May 2009
Author:demon
Status:ok (Comments)
Tags:
Comment:
* Use two separate functions, $wgParser might not be the parser in ParserFirstCallInit, so use the hook properly
* Add three todo's
Modified paths:
  • /trunk/extensions/TSPoll/TSPoll.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TSPoll/TSPoll.php
@@ -37,7 +37,7 @@
3838 if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
3939 $wgHooks['ParserFirstCallInit'][] = 'efTSPollSetup';
4040 } else { // Otherwise do things the old fashioned way
41 - $wgExtensionFunctions[] = 'efTSPollSetup';
 41+ $wgExtensionFunctions[] = 'efTSPollSetupHook';
4242 }
4343
4444 $wgExtensionMessagesFiles['TSPoll'] = dirname( __FILE__ ) . '/TSPoll.i18n.php';
@@ -50,6 +50,12 @@
5151 return true;
5252 }
5353
 54+function efTSPollSetupHook( &$parser ) {
 55+ $parser->setHook( 'TSPoll', 'efTSPollRender' );
 56+ $parser->setHook( 'tspoll', 'efTSPollRender' );
 57+ return true;
 58+}
 59+
5460 function efTSPollRender( $input, $args, $parser ) {
5561
5662 if ( isset( $args['id'] ) ) {
@@ -58,14 +64,17 @@
5965 // @todo: maybe output an error?
6066 $id = '';
6167 }
62 -
 68+
 69+ // @todo Can't we just use the Http class?
6370 $http = new http_w( 'toolserver.org', '/~jan/poll/main.php?page=wiki_output&id=' . $id );
6471 $get_server = $http->get( '' );
 72+ // @todo If false? How can this ever be true?
6573 if( false&& $get_server != '' ) {
6674 return $get_server;
6775 }
6876 else {
6977 wfLoadExtensionMessages( 'TSPoll' );
 78+ // @todo: Should this be parsing before returning?
7079 return wfMsgExt( 'tspoll-fetch-error', array( 'parse' ) );
7180 }
7281 }

Comments

#Comment by Jan Luca (talk | contribs)   16:45, 2 May 2009

Which http class?

#Comment by 😂 (talk | contribs)   16:54, 2 May 2009

See /includes/HttpFunctions.php, we've got a ready-to-use Http class that has static get() and post() methods. Generally, we just use these rather than re-inventing the wheel :)

Status & tagging log