From 63aeabeff1e098e872cc46f3698c61457e44ba15 Mon Sep 17 00:00:00 2001 From: Arlo Breault Date: Thu, 21 Jan 2016 19:24:03 -0800 Subject: [PATCH] Last caption wins in gallery * Currently, for images: [[File:Foobar.jpg|hi|alt=100|ho]] caption: ho but for galleries: File:Foobar.jpg|hi|alt=100|ho caption: hi|ho * This patch brings some consistency to them. Change-Id: I3b73189b27cc35fade4809477cf18779b953aa3b --- RELEASE-NOTES-1.27 | 2 ++ includes/parser/Parser.php | 10 +++++----- tests/parser/parserTests.txt | 8 +++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27 index def80ea846..01a802ac06 100644 --- a/RELEASE-NOTES-1.27 +++ b/RELEASE-NOTES-1.27 @@ -287,6 +287,8 @@ changes to languages because of Phabricator reports. * ParserOutput::hasCustomDataUpdates() was removed (deprecated since 1.25). * ParserOutput::addSecondaryDataUpdate() was removed (deprecated since 1.25). * ParserOutput::getSecondaryDataUpdates() was removed (deprecated since 1.25). +* Gallery images with multiple caption pipes no longer concatenate them all + together but instead pick the final one, similar to image syntax. == Compatibility == diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 7b4a65074b..5f7e89ce7d 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -5442,18 +5442,18 @@ class Parser { if ( $handler->validateParam( $paramName, $match ) ) { $handlerOptions[$paramName] = $match; } else { - // Guess not. Append it to the caption. + // Guess not, consider it as caption. wfDebug( "$parameterMatch failed parameter validation\n" ); - $label .= '|' . $parameterMatch; + $label = '|' . $parameterMatch; } } } else { - // concatenate all other pipes - $label .= '|' . $parameterMatch; + // Last pipe wins. + $label = '|' . $parameterMatch; } } - // remove the first pipe + // Remove the pipe. $label = substr( $label, 1 ); } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 438fe314ca..61c331da8c 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -18300,8 +18300,6 @@ image4 |300px| centre
  • Image2.gif
    -

    |||| -

  • @@ -18312,8 +18310,8 @@ image4 |300px| centre
  • Image4
    -

    300px| centre -

    +
    centre
    +
  • @@ -18372,7 +18370,7 @@ image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
  • This is a foo-bar.
    -

    Blabla|blabla. +

    blabla.

  • -- 2.20.1