Page MenuHomePhabricator

Error: Call to a member function getMimeType() on null
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Error: Call to a member function getMimeType() on null
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.21/extensions/PageImages/includes/Hooks/SearchResultProvideThumbnailHookHandler.php(100)
#0 /srv/mediawiki/php-1.37.0-wmf.21/extensions/PageImages/includes/Hooks/SearchResultProvideThumbnailHookHandler.php(122): PageImages\Hooks\SearchResultProvideThumbnailHookHandler->getThumbnails(array, integer)
#1 /srv/mediawiki/php-1.37.0-wmf.21/extensions/PageImages/includes/Hooks/SearchResultProvideThumbnailHookHandler.php(141): PageImages\Hooks\SearchResultProvideThumbnailHookHandler->doSearchResultProvideThumbnail(array, array)
#2 /srv/mediawiki/php-1.37.0-wmf.21/includes/HookContainer/HookContainer.php(338): PageImages\Hooks\SearchResultProvideThumbnailHookHandler::onSearchResultProvideThumbnail(array, array)
#3 /srv/mediawiki/php-1.37.0-wmf.21/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#4 /srv/mediawiki/php-1.37.0-wmf.21/includes/HookContainer/HookRunner.php(3250): MediaWiki\HookContainer\HookContainer->run(string, array)
#5 /srv/mediawiki/php-1.37.0-wmf.21/includes/Rest/Handler/SearchHandler.php(299): MediaWiki\HookContainer\HookRunner->onSearchResultProvideThumbnail(array, array)
#6 /srv/mediawiki/php-1.37.0-wmf.21/includes/Rest/Handler/SearchHandler.php(328): MediaWiki\Rest\Handler\SearchHandler->buildThumbnailsFromPageIdentities(array)
#7 /srv/mediawiki/php-1.37.0-wmf.21/includes/Rest/Router.php(403): MediaWiki\Rest\Handler\SearchHandler->execute()
#8 /srv/mediawiki/php-1.37.0-wmf.21/includes/Rest/Router.php(330): MediaWiki\Rest\Router->executeHandler(MediaWiki\Rest\Handler\SearchHandler)
#9 /srv/mediawiki/php-1.37.0-wmf.21/includes/Rest/EntryPoint.php(165): MediaWiki\Rest\Router->execute(MediaWiki\Rest\RequestFromGlobals)
#10 /srv/mediawiki/php-1.37.0-wmf.21/includes/Rest/EntryPoint.php(130): MediaWiki\Rest\EntryPoint->execute()
#11 /srv/mediawiki/php-1.37.0-wmf.21/rest.php(31): MediaWiki\Rest\EntryPoint::main()
#12 /srv/mediawiki/w/rest.php(3): require(string)
#13 {main}
Impact

It might well break the search drop list? A request to https://fr.wikipedia.org/w/rest.php/v1/search/title?q=circu&limit=10 yields empty content after roughly 35 seconds.

Similar ones based on the URL being called:

WikiSearch term(s)
frwikicirc circu circuit holde
frwiktionaryco
ptwikicobre
euwikih
srwikipla plan

I guess cause some thumbnail have faults?

Notes

The first event was at Sep 13th 2021 19:57:55 UTC for frwiki with the query royaume des.

Histogram of events in Kibana:

thumberror.png (239×669 px, 15 KB)

Event Timeline

Might be related T290759:

19:52 	<jforrester@deploy1002> 	Synchronized wmf-config/InitialiseSettings.php: T290759 Undeploy VipsScaler: I – Disable on all wikis (duration: 00m 57s)

That was to drop https://www.mediawiki.org/wiki/VipsScaler which was to generate thumbnails.

The code choke at when trying to get a thumbnail mimetype although one apparently got returned:

includes/Hooks/SearchResultProvideThumbnailHookHandler.php
 82         $files = $this->getFileNamesForPageTitles( $pagesByPageId )
 83             + $this->getFileNamesForFileTitles( $titleFilesByPageId );
 84 
 85         $res = [];
 86         foreach ( $files as $pageId => $fileName ) {
 87             $file = $this->repoGroup->findFile( $fileName );
 88             if ( !$file ) {
 89                 continue;
 90             }
 91             $thumb = $file->transform( [ 'width' => $size , 'height' => $size ] );
 92             if ( !$thumb ) {
 93                 continue;
 94             }
 95 
 96             $localPath = $thumb->getLocalCopyPath();
 97             $thumbSize = $localPath && file_exists( $localPath ) ? filesize( $localPath ) : null;
 98 
 99             $res[$pageId] = new SearchResultThumbnail(
100                 $thumb->getFile()->getMimeType(),    # <--------------------------
101                 $thumbSize,
102                 $thumb->getWidth(),
103                 $thumb->getHeight(),
104                 null,
105                 wfExpandUrl( $thumb->getUrl(), PROTO_RELATIVE ),
106                 $fileName
107             );

For vips specifically, I looked through exec.log before bringing it up that the only invocations of vips in the past 30 days was from Special:VipsTest.

Did we miss this? Or is it just happenstance and this wasn't going through Vips?

It definitely was not shelling out to vips (unless we're missing entries from exec.log). I'm having a hard time tracing all the file logic... VipsScaler hooks into BitmapHandlerTransform, which is called in TransformationalImageHandler::doTransform(). But even then, it shouldn't affect the response of File::transform.

I do think PageImages needs to check $thumb->isError() first, and that might do the trick?

Change 721027 had a related patch set uploaded (by Legoktm; author: Legoktm):

[mediawiki/extensions/PageImages@master] Check $thumb->isError() before trying to use it

https://gerrit.wikimedia.org/r/721027

Change 721027 merged by jenkins-bot:

[mediawiki/extensions/PageImages@master] Check $thumb->isError() before trying to use it

https://gerrit.wikimedia.org/r/721027

Change 720857 had a related patch set uploaded (by Jforrester; author: Legoktm):

[mediawiki/extensions/PageImages@REL1_37] Check $thumb->isError() before trying to use it

https://gerrit.wikimedia.org/r/720857

Change 720858 had a related patch set uploaded (by Jforrester; author: Legoktm):

[mediawiki/extensions/PageImages@wmf/1.37.0-wmf.23] Check $thumb->isError() before trying to use it

https://gerrit.wikimedia.org/r/720858

Change 720859 had a related patch set uploaded (by Jforrester; author: Legoktm):

[mediawiki/extensions/PageImages@wmf/1.37.0-wmf.22] Check $thumb->isError() before trying to use it

https://gerrit.wikimedia.org/r/720859

Change 720857 merged by jenkins-bot:

[mediawiki/extensions/PageImages@REL1_37] Check $thumb->isError() before trying to use it

https://gerrit.wikimedia.org/r/720857

Change 720865 had a related patch set uploaded (by Jforrester; author: Legoktm):

[mediawiki/extensions/PageImages@wmf/1.37.0-wmf.21] Check $thumb->isError() before trying to use it

https://gerrit.wikimedia.org/r/720865

Change 720859 abandoned by Jforrester:

[mediawiki/extensions/PageImages@wmf/1.37.0-wmf.22] Check $thumb->isError() before trying to use it

Reason:

We didn't deploy wmf.22.

https://gerrit.wikimedia.org/r/720859

VipsScaler is back for now, we'll make sure this doesn't regress when removing it again.

Looks fixed to me. Thank you @Legoktm for the quick fixes!

Change 720865 abandoned by Jforrester:

[mediawiki/extensions/PageImages@wmf/1.37.0-wmf.21] Check $thumb->isError() before trying to use it

Reason:

wmf.21 isn't deployed anywhere any more.

https://gerrit.wikimedia.org/r/720865