Page MenuHomePhabricator

array_map() callback error
Closed, ResolvedPublic

Description

Feb 16 12:38:53 10.0.8.1 apache2[11835]: PHP Warning: array_map() [<a href='function.array-map'>function.array-map</a>]: An error occurred while invoking the map callback in /usr/local/apache/common-local/php-1.17/extensions/OpenSearchXml/ApiOpenSearchXml.php on line 85

Logging as a TODO if we can find out how to replicate....


Version: unspecified
Severity: normal

Details

Reference
bz27452

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:20 PM
bzimport set Reference to bz27452.

The PHP warning message here indicates an exception (or possibly some other error, but I can definitely reproduce it with an exception) in the callback function to array_map() -- this seems to happen even if the exception is caught, which is pretty lame.

The only array_map() call here is to $this->formatItem(), so most likely something in there or in the many things called from there had an error.

There should have been a separate log line for errors or exceptions in there, which might make it rather easier to track down the specific issue.

Without that there may be nothing too specific to look at if nothing pops out; if this is a frequent error rather than a one-off, consider adding some debug logging around it, possibly a try/catch which can add logging if an exception is indeed being thrown in there.

Reedy, does this still happen in logs?

I can't see anything obvious.

IIRC this was something Tim noticed was happening fairly regularly around/just after the 1.17 deploy

reedy@fenari:/home/wikipedia/l$ grep OpenSearchXml *.log
reedy@fenari:/home/wikipedia/l$ grep OpenSearch *.log
runJobs.log:2011-05-25 09:36:55 srv232 enwiki: enotifNotify OpenSearch editor=217.195.212.206 editorID=0 timestamp=20110525093652 summary=/* Search engines and software that support OpenSearch */ minorEdit=0 oldid=420659461 watchers=Array t=1 good
slow-parse.log:2011-05-25 08:06:08 srv175 enwiki: 4.72 OpenSearch
xff.log:Wed, 25 May 2011 09:36:48 +0000 http://en.wikipedia.org/w/index.php?title=OpenSearch&action=submit 217.195.212.206, 91.198.174.37, 91.198.174.40, 208.80.152.72 save

I'll mark it was resolved wfm

Update for completeness...

During the 1.18wmf1 migration this seemed to have batches of it occurring again.

Did do some hacking

		$srchres = PrefixSearch::titleSearch( $search, $limit, $namespaces );

		if ( !is_array( $srchres ) ) {
			wfDebug( 'PrefixSearch::titleSearch returned a non array', true );
			$srchres = array();
		}
		$mapped = array_map( array( $this, 'formatItem' ), $srchres );
		$items = array_filter( $mapped );

But not sure if it actually did anything, or the issue was just transient

Reopening due to the current error spammage

Oct 5 23:44:54 10.0.2.187 apache2[6888]: PHP Warning: array_map() [<a href='function.array-map'>function.array-map</a>]: An error occurred while invoking the map callback in /usr/local/apache/common-local/php-1.18/extensions/OpenSearchXml/ApiOpenSearchXml.php on line 88
Oct 5 23:44:54 10.0.8.47 apache2[17441]: PHP Warning: array_map() [<a href='function.array-map'>function.array-map</a>]: An error occurred while invoking the map callback in /usr/local/apache/common-local/php-1.18/extensions/OpenSearchXml/ApiOpenSearchXml.php on line 88
Oct 5 23:44:54 10.0.8.43 apache2[12300]: PHP Warning: array_map() [<a href='function.array-map'>function.array-map</a>]: An error occurred while invoking the map callback in /usr/local/apache/common-local/php-1.18/extensions/OpenSearchXml/ApiOpenSearchXml.php on line 88
Oct 5 23:44:54 10.0.2.218 apache2[7722]: PHP Warning: array_map() [<a href='function.array-map'>function.array-map</a>]: An error occurred while invoking the map callback in /usr/local/apache/common-local/php-1.18/extensions/OpenSearchXml/ApiOpenSearchXml.php on line 88

This error indicates that the formatItem method used as the callback to array_map threw an exception -- you would get a different error if a non-array had been returned.

ApiMain::execute() seems to wrap things in a try/catch by default, so whatever the exception was may have been separately logged to wfDebugLog('exception') (or apparently not logged at all if it wasn't a MWException).

(In reply to comment #7)

This error indicates that the formatItem method used as the callback to
array_map threw an exception -- you would get a different error if a non-array
had been returned.

FYI, this is https://bugs.php.net/bug.php?id=55416

1 Warning: array_map() [<a href='function.array-map'>function.array-map</a>]: An error occurred while invoking the map callback in /usr/local/apache/common-local
/php-1.20wmf1/extensions/OpenSearchXml/ApiOpenSearchXml.php on line 0

Still happening. I guess it's moar PHP fail