Page MenuHomePhabricator

Wrong parser hooks getting called
Open, Needs TriagePublic

Description

This is probably an issue with core MediaWiki Parser or my implementation of the extension.

I have a custom extension that defines various parser hooks, as the code is not open source I am sharing a small version of the code with relevant parts.

  $wgHooks['ParserFirstCallInit'][] = 'wfSampleSetup';

  function wfSampleSetup( Parser $parser ) {
 	$parser->setHook( 'xyz', 'xyzRender' );
  	$parser->setHook( 'abc', 'abcRender' );
  }

  function xyzRender( $input, array $args, Parser $parser, PPFrame $frame ) {
     ...
  }

  function abcRender( $input, array $args, Parser $parser, PPFrame $frame ) {
     if (empty($input)) {
 	header('Location: http://www.website.com');
	die();
     }
     ...
  }

On pages that have 'abc' with empty 'input' it should redirect to the homepage. However pages with content 'xyz' also seem to be calling abcRender() and redirecting to the website homepage.

I tried to print the stack trace just before the redirect call and it seems that the fn is getting called from:
extensionSubstitution in Parser.php

Event Timeline

Per PHP: function die; die doesn't prevent destructors from being run, so the script doesn't exit immediately, it still goes through cleanup routines.