Page MenuHomePhabricator

Warning: in_array() [function.in-array]: Wrong datatype for second argument in ParserOptions.php
Closed, ResolvedPublic

Description

I believe the error message (see http://www.keytonature.eu/wiki/Test ) depends on the google maps extension only, so I suspect the root cause is in the extension, although the error reports to a core module.

Version is trunk (http://www.keytonature.eu/wiki/Special:Version).


Version: 1.18.x
Severity: critical
URL: http://www.keytonature.eu/wiki/Test

Details

Reference
bz27543

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:22 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz27543.
bzimport added a subscriber: Unknown Object (MLST).

helix wrote:

I think that this error has nothing to do with the extension.

PHP Warning: in_array() expects parameter 2 to be array, boolean given in /htdocs/includes/parser/ParserOptions.php on line 297

Seems like there is a wrong in_array call in the ParserOptions.php on line 297, 302 and 317

helix wrote:

Looks like my last comment was total crap.
But I have the same problem with the DynamicPageList extension.

http://www.mediawiki.org/wiki/Extension:DynamicPageList_(third-party)

gero.scholz wrote:

I maintain DPL and I think the problem lies in ParserOutput.php, line 339.

function getUsedOptions returns "false" if no options exist, but later in ParserCache.php, line 186 the result is passed to ParserOptions.php, function optionsHash(..); This function is not aware of the fact that its argument might not be an array.

I suggest the following BUGFIX:

/**

  • Returns the options from its ParserOptions which have been taken
  • into account to produce this output or false if not available.
  • @return mixed Array/false
	 */
	 public function getUsedOptions() {
		if ( !isset( $this->mAccessedOptions ) ) {
			return array();  // BUGFIX: return empty array !! 
			return false;
		}
		return array_keys( $this->mAccessedOptions );
	 }

This bugxif works with DPL and I am pretty sure it will also avoid the same error with any other extension ....

gero.scholz wrote:

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

redekopmark wrote:

Gero's solution fixed my wiki's problems, any chance of this being included in 1.18 so we don't have to keep patching it?

john wrote:

Gero's fix

Attached: