From ad0746110ce04f33244d747f60291bbdb8450499 Mon Sep 17 00:00:00 2001 From: Arlo Breault Date: Thu, 16 Dec 2021 21:23:20 -0500 Subject: [PATCH] Match output for broken thumbnails Follow up to the FIXME added in I6d03037af1b5c90e6d57fd048506da2b4e4bc704 The output isn't great but at least it matches Parsoid's. Change-Id: I5660b8ccdb8bd0c89b94669a1c6ab260d57183df --- includes/Linker.php | 11 ++++++++--- tests/parser/mediaParserTests.txt | 3 +-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index 48a4413e16c..7caaad978c1 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -714,8 +714,13 @@ class Linker { ); $zoomIcon = ''; } elseif ( !$thumb ) { - // FIXME(T169975): Add "mw:Error"? - $s .= wfMessage( 'thumbnail_error', '' )->escaped(); + if ( $enableLegacyMediaDOM ) { + $s .= wfMessage( 'thumbnail_error', '' )->escaped(); + } else { + $s .= self::makeBrokenImageLinkObj( + $title, '', '', '', '', (bool)$time, $handlerParams + ); + } $zoomIcon = ''; } else { if ( !$noscale && !$manualthumb ) { @@ -768,7 +773,7 @@ class Linker { $rdfaType = 'mw:Image' . $rdfaType; } - if ( !$exists ) { + if ( !$exists || !$thumb ) { $rdfaType = 'mw:Error ' . $rdfaType; } diff --git a/tests/parser/mediaParserTests.txt b/tests/parser/mediaParserTests.txt index 75d6865966b..effb5bac17a 100644 --- a/tests/parser/mediaParserTests.txt +++ b/tests/parser/mediaParserTests.txt @@ -2261,7 +2261,6 @@ wgParserEnableLegacyMediaDOM=false

Image:No such.jpg

!! end -## FIXME: The legacy parser output doesn't match Parsoid here !! test Fuzz testing: image with bogus manual thumbnail !! config @@ -2269,7 +2268,7 @@ wgParserEnableLegacyMediaDOM=false !! wikitext [[Image:foobar.jpg|thumbnail= ]] !! html/php -
Error creating thumbnail:
+
File:Foobar.jpg
!! html/parsoid
File:Foobar.jpg
!! end