Page MenuHomePhabricator

PHP Warning: get_class() expects parameter 1 to be object, unknown given
Open, Needs TriagePublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   PHP Warning: get_class() expects parameter 1 to be object, unknown given
exception.trace
from /srv/mediawiki/php-1.40.0-wmf.6/includes/exception/MWExceptionHandler.php(495)
#0 /srv/mediawiki/php-1.40.0-wmf.6/includes/exception/MWExceptionHandler.php(495): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 [internal function]: MWExceptionHandler::{closure}()
#2 /srv/mediawiki/php-1.40.0-wmf.6/includes/exception/MWExceptionHandler.php(496): array_map(Closure, array)
#3 [internal function]: MWExceptionHandler::{closure}(array)
#4 /srv/mediawiki/php-1.40.0-wmf.6/includes/exception/MWExceptionHandler.php(499): array_map(Closure, array)
#5 /srv/mediawiki/php-1.40.0-wmf.6/includes/exception/MWExceptionHandler.php(478): MWExceptionHandler::redactTrace(array)
#6 /srv/mediawiki/php-1.40.0-wmf.6/includes/exception/MWExceptionHandler.php(651): MWExceptionHandler::getRedactedTrace(Wikimedia\RequestTimeout\RequestTimeoutException)
#7 /srv/mediawiki/php-1.40.0-wmf.6/includes/exception/MWExceptionHandler.php(723): MWExceptionHandler::getStructuredExceptionData(Wikimedia\RequestTimeout\RequestTimeoutException, string)
#8 /srv/mediawiki/php-1.40.0-wmf.6/includes/exception/MWExceptionHandler.php(756): MWExceptionHandler::jsonSerializeException(Wikimedia\RequestTimeout\RequestTimeoutException, boolean, integer, string)
#9 /srv/mediawiki/php-1.40.0-wmf.6/includes/exception/MWExceptionHandler.php(193): MWExceptionHandler::logException(Wikimedia\RequestTimeout\RequestTimeoutException, string)
#10 /srv/mediawiki/php-1.40.0-wmf.6/includes/Rest/Reporter/MWErrorReporter.php(25): MWExceptionHandler::rollbackPrimaryChangesAndLog(Wikimedia\RequestTimeout\RequestTimeoutException, string)
#11 /srv/mediawiki/php-1.40.0-wmf.6/includes/Rest/Router.php(410): MediaWiki\Rest\Reporter\MWErrorReporter->reportError(Wikimedia\RequestTimeout\RequestTimeoutException, MWParsoid\Rest\Handler\PageHandler, MediaWiki\Rest\RequestFromGlobals)
#12 /srv/mediawiki/php-1.40.0-wmf.6/includes/Rest/EntryPoint.php(170): MediaWiki\Rest\Router->execute(MediaWiki\Rest\RequestFromGlobals)
#13 /srv/mediawiki/php-1.40.0-wmf.6/includes/Rest/EntryPoint.php(135): MediaWiki\Rest\EntryPoint->execute()
#14 /srv/mediawiki/php-1.40.0-wmf.6/rest.php(31): MediaWiki\Rest\EntryPoint::main()
#15 /srv/mediawiki/w/rest.php(3): require(string)
#16 {main}
Notes
  • Looks like invalid json being passed from Rest/Router and MediaWiki exception handler is choking on it
  • Happening infrequently, but has happened for a long time.

Details

Request URL
https://de.wikibooks.org/w/rest.php/de.wikibooks.org/v3/page/pagebundle/*

Event Timeline

php-1.40.0-wmf.6/includes/exception/MWExceptionHandler.php(495) is the redactTrace method and the line is:

return is_object( $arg ) ? get_class( $arg ) : gettype( $arg );

So somehow the trace has a $arg which is considered an object by is_object but is not an object when passed through get_class. I am pretty sure the trace being redacted is a Wikimedia\RequestTimeout\RequestTimeoutException thrown by the rest entry point.

We had wikimedia/request-timeout bumped from 1.1.0 to 1.2.0 by d3cb44a6e7c5baed9e0b369fb56ecbe52e5490b9 but that was back in February 2022.

Note the error reason unknown given

SLopes-WMF subscribed.

Doesn't seem to be a Parsoid-related issue.

This is an issue with MWExceptionHandler. RestBase throws an exception, MWExceptionHandler tries to format it as a nice human-readable string, which includes going through the stack trace and converting each of the function call arguments to some string representation, and that triggers get_class() expects parameter 1 to be object, unknown given which is rather curious (how can PHP not know the type?).

Few more instances of that one on Commons on June 14th 2023, e.g reqId: eb493356-b3b6-4b63-814c-e039e7df9764 Find reqId in Logstash