diff options
author | Matthias Mullie <git@mullie.eu> | 2022-10-13 09:41:36 +0200 |
---|---|---|
committer | Matthias Mullie <mmullie@wikimedia.org> | 2022-10-13 10:05:54 +0000 |
commit | 2856fcc2c014bdeb7045a002ea52d56ce2422f9b (patch) | |
tree | 59b198bc9d02d04d5dbaf7974960e7fa454d43bf | |
parent | 8d7b331a7603ff6572af66926ae7b1f24308cb30 (diff) |
Commons files can have thumbnails toowmf/1.40.0-wmf.4
A previous commit, I22c2ab886b3a1b1fdf2df062ffa76cd00d4d25fd,
introduced these too-strict checks to ensure that interwiki
results (which can appear below regular results) don't cause
errors; after all, they're not pages that we can really handle
on this wiki.
As said, these checks are currently too strict: they also
exclude Commons files, which appear within the main search
results. We can (and should) serve thumbnails for these
results - all of that is baked into MW.
The difference between these Commons and other-interwiki
results is that, while both don't actually exist on this wiki
(exists() === false), the former is not considered external
(isExternal() === false) and doesn't fail canExist().
Change-Id: I3952ab6d0098afc7c312db2b9410e8b436f2e486
(cherry picked from commit de88bfc53225ccfcda33d31de41c552290f72ebc)
-rw-r--r-- | includes/search/searchwidgets/FullSearchResultWidget.php | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/includes/search/searchwidgets/FullSearchResultWidget.php b/includes/search/searchwidgets/FullSearchResultWidget.php index 55a8600f7567..496fec6534c6 100644 --- a/includes/search/searchwidgets/FullSearchResultWidget.php +++ b/includes/search/searchwidgets/FullSearchResultWidget.php @@ -279,8 +279,8 @@ class FullSearchResultWidget implements SearchResultWidget { */ protected function generateFileHtml( SearchResult $result ) { $title = $result->getTitle(); - // don't assume that result is a valid title; e.g. could be interwiki page - if ( $title === null || !$title->canExist() || !$title->exists() ) { + // don't assume that result is a valid title; e.g. could be an interwiki link target + if ( $title === null || !$title->canExist() ) { return [ '', null, null ]; } @@ -318,14 +318,14 @@ class FullSearchResultWidget implements SearchResultWidget { */ private function getThumbnail( SearchResult $result, int $size ): ?SearchResultThumbnail { $title = $result->getTitle(); - // don't assume that result is a valid title; e.g. could be interwiki page - if ( $title === null || !$title->canExist() || !$title->exists() ) { + // don't assume that result is a valid title; e.g. could be an interwiki link target + if ( $title === null || !$title->canExist() ) { return null; } - $thumbnails = $this->thumbnailProvider->getThumbnails( [ $title->getId() => $title ], $size ); + $thumbnails = $this->thumbnailProvider->getThumbnails( [ $title->getArticleID() => $title ], $size ); - return $thumbnails[ $title->getId() ] ?? null; + return $thumbnails[ $title->getArticleID() ] ?? null; } /** @@ -335,8 +335,8 @@ class FullSearchResultWidget implements SearchResultWidget { */ private function generateThumbnailHtml( SearchResult $result, SearchResultThumbnail $thumbnail = null ): ?string { $title = $result->getTitle(); - // don't assume that result is a valid title; e.g. could be interwiki page - if ( $title === null || !$title->canExist() || !$title->exists() ) { + // don't assume that result is a valid title; e.g. could be an interwiki link target + if ( $title === null || !$title->canExist() ) { return null; } |