Ensure array is passed to getProperties

PageImages::getPropNames can return either array or string,
and PageProps::getProperties accepts both.
But the latter's return value will be different depending
on the type of input: with an array as input, the returned
array's values will be an associative array where the index
is the propname; with a string, it's just the propvalue.

This difference matters because the code below assumes an
array with propname keys.

Bug: T323152
Change-Id: I422951ec0cd5c651b32c65e88a557d49f2f22712
This commit is contained in:
Matthias Mullie 2022-11-16 09:14:13 +01:00
parent d7d9c0275f
commit c75b00d14d
2 changed files with 2 additions and 2 deletions

View file

@ -53,7 +53,7 @@ class SearchResultProvideThumbnailHookHandler implements SearchResultProvideThum
$propValues = $this->pageProps->getProperties(
$nonFileIdentitiesByPageId,
// T320661: only provide free images for search purposes
PageImages::getPropNames( PageImages::LICENSE_FREE )
(array)PageImages::getPropNames( PageImages::LICENSE_FREE )
);
$fileNames = array_map( static function ( $prop ) {
return $prop[ PageImages::getPropName( false ) ]

View file

@ -116,7 +116,7 @@ class SearchResultProvideThumbnailHookHandlerTest extends MediaWikiIntegrationTe
->method( 'getProperties' )
->with(
$this->anything(),
PageImages::getPropNames( PageImages::LICENSE_FREE )
(array)PageImages::getPropNames( PageImages::LICENSE_FREE )
)->willReturn( [
1 => [
PageImages::getPropName( true ) => 'File1_free.jpg'