r74182 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74181‎ | r74182 | r74183 >
Date:01:50, 3 October 2010
Author:brion
Status:ok
Tags:
Comment:
ProofreadPage: Use modern system for setting up parser hooks (ParserFirstCallInit) rather than attempting to set it on $wgParser at system init time
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php
@@ -32,11 +32,9 @@
3333 /**
3434 * Constructor
3535 */
36 - function ProofreadPage() {
37 - global $wgParser, $wgHooks, $wgScriptPath;
38 - $wgParser->setHook( 'pagelist', array( &$this, 'renderPageList' ) );
39 - $wgParser->setHook( 'pages', array( &$this, 'renderPages' ) );
40 - $wgParser->setHook( 'pagequality', array( &$this, 'pageQuality' ) );
 36+ function __construct() {
 37+ global $wgHooks, $wgScriptPath;
 38+ $wgHooks['ParserFirstCallInit'][] = array( $this, 'parserFirstCallInit' );
4139 $wgHooks['BeforePageDisplay'][] = array( &$this, 'beforePageDisplay' );
4240 $wgHooks['GetLinkColours'][] = array( &$this, 'getLinkColoursHook' );
4341 $wgHooks['ImageOpenShowImageInlineBefore'][] = array( &$this, 'imageMessage' );
@@ -71,6 +69,19 @@
7270
7371 }
7472
 73+ /**
 74+ * Set up our custom parser hooks when initializing parser.
 75+ *
 76+ * @param Parser $parser
 77+ * @return boolean hook return value
 78+ */
 79+ public function parserFirstCallInit( $parser ) {
 80+ $parser->setHook( 'pagelist', array( $this, 'renderPageList' ) );
 81+ $parser->setHook( 'pages', array( $this, 'renderPages' ) );
 82+ $parser->setHook( 'pagequality', array( $this, 'pageQuality' ) );
 83+ return true;
 84+ }
 85+
7586 public static function resourceLoaderRegisterModules( &$resourceLoader ) {
7687 $resourceLoader->register(
7788 'ext.proofreadpage.page',

Status & tagging log