Skip to content

Commit

Permalink
Return early for cover images that are not found
Browse files Browse the repository at this point in the history
BookProvider::getCover() was already returning for no pages
returned, so this switches to API formatversion 2 and also
checks for the `missing` or `invalid` parameter in the first/only returned
page.

Bug: T370257
  • Loading branch information
samwilson authored Aug 19, 2024
1 parent bb33d8e commit aadedad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/BookProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,13 @@ public function getCover( $cover ): ?Picture {
'iiprop' => 'thumbmime|dimensions|url|canonicaltitle',
'iiurlparam' => $urlParam,
'iiurlwidth' => $width,
'formatversion' => 2,
] )->wait();
if ( !isset( $response['query']['pages'] ) ) {
// Give up for invalid cover titles or those that do not exist.
if ( !isset( $response['query']['pages'] )
|| isset( $response['query']['pages'][0]['missing'] )
|| isset( $response['query']['pages'][0]['invalid'] )
) {
return null;
}

Expand Down

0 comments on commit aadedad

Please sign in to comment.