Page MenuHomePhabricator

InputBox SVN doesn't work with MediaWiki 1.14alpha SVN
Closed, ResolvedPublic

Description

Author: nsk

Description:
InputBox (Version r42791) does not work with MediaWiki 1.14alpha (r43105) and 1.14alpha (r43194) (I tested both revisions). In short, InputBox SVN HEAD doesn't work with MediaWiki SVN HEAD.

No input box is outputted when trying to output one.

Previewing a page with an input box (which is not shown due to the bug) produced this php warning:

Warning: call_user_func_array() [function.call-user-func-array]: Unable to call InputBoxHooks::render() in /includes/parser/Parser.php on line 3330


Version: unspecified
Severity: blocker

Details

Reference
bz16242

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:21 PM
bzimport set Reference to bz16242.

nsk wrote:

The extension is installed in LocalSettings.php as follows:

require_once($IP.'/extensions/InputBox/InputBox.php');

thomas.hempel wrote:

This is easy to fix, and you can simplify the code. Basically get rid of the Inputbox.hooks.php.

  1. In Inputbox.php replace everything from line 50 on with:

Register parser hook
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
Modern
$wgHooks['ParserFirstCallInit'][] = 'wfInputBox';
} else {
// Legacy
$wgExtensionFunctions[] = 'wfInputBox';
}

function wfInputBox ()
{

new InputBox;
return true;

}

2.In Inputbox.classes.php get rid of the __construct function and replace it with:
function InputBox() {

	        global $wgParser;
		
		$wgParser->setHook( 'inputbox' , array( &$this, 'render' ) );
        }

public function render( $input, $args, $parser ) {

		$this->mParser = $parser;	       

		// Configure InputBox
		$this->extractOptions( $parser->replaceVariables( $input ) );

		// Return output
		return $this->render();

}

and you're done!

thomas.hempel wrote:

sorry, there's a typo in the render() above, it should be:
public function render( $input, $args, $parser ) {

		$this->mParser = $parser;	       

		// Configure InputBox
		$this->extractOptions( $parser->replaceVariables( $input ) );


		// Internationalization

(continuing as before)
tom

  • Bug 16246 has been marked as a duplicate of this bug. ***

This was probably due to changes in Hooks.php which I reverted in r43416.

thomas.hempel wrote:

No, it's still just as broken as ever. Same issue as before.
tom

Works just fine here. PHP version?

nsk wrote:

Thanks for looking at this. Here it's mediawiki 1.14alpha (r43263), php 5.2.0-8+etch13 (apache2handler), mysql 5.0.32-Debian_7etch8-log.

thomas.hempel wrote:

Here's a simpler view of it. It's the same as an issue that Rob Church documented for Extension:RandomImage.
The problem is a statement of the form:
$wgparser->setHook( 'randomimage', 'RandomImage::renderHook' );
Yhe problem goes away if you do:
$wgParser->setHook( 'randomimage', array('RandomImage', 'renderHook'));
Hope that helps.

Those are *function hooks* which are called directly with call_user_func_array() and must be a PHP callable.

Things in $wgHooks are *not* directly called; they are parsed and munged and, for backwards compatibility, we have retained that.

The relevant part of wfRunHooks() in Hooks.php is:

} elseif ( false !== ( $pos = strpos( $func, '::' ) ) ) {
$callback = array( substr( $func, 0, $pos ), substr( $func, $pos + 2 ) );
} else {

This will translate the 'InputBoxHooks::register' into array('InputBoxHooks','register') which is the actual callable.

Can you confirm that you have a current version of both InputBox and MediaWiki trunk? Confirm that your Hooks.php is current, and does not have the broken version which broke these calls.

Can you then do some debugging to check the actual value of the callable at the time it's called in wfRunHooks()?

Ahhhh it's the render, not the register that you're seeing. Your sample code referring to the *register* function's registration -- which is entirely set up correctly -- threw me off.

Fixed in r43504.

thomas.hempel wrote:

yes, that fixes it. Thanks!