Last caption wins in gallery
authorArlo Breault <abreault@wikimedia.org>
Fri, 22 Jan 2016 03:24:03 +0000 (19:24 -0800)
committerArlo Breault <abreault@wikimedia.org>
Fri, 22 Jan 2016 19:22:06 +0000 (11:22 -0800)
 * Currently, for images:

   [[File:Foobar.jpg|hi|alt=100|ho]]

   caption: ho

   but for galleries:

   <gallery>
   File:Foobar.jpg|hi|alt=100|ho
   </gallery>

   caption: hi|ho

 * This patch brings some consistency to them.

Change-Id: I3b73189b27cc35fade4809477cf18779b953aa3b

RELEASE-NOTES-1.27
includes/parser/Parser.php
tests/parser/parserTests.txt

index def80ea..01a802a 100644 (file)
@@ -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 ==
 
index 7b4a650..5f7e89c 100644 (file)
@@ -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 );
                        }
 
index 438fe31..61c331d 100644 (file)
@@ -18300,8 +18300,6 @@ image4    |300px| centre
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
                        <div class="thumb" style="height: 150px;">Image2.gif</div>
                        <div class="gallerytext">
-<p>||||
-</p>
                        </div>
                </div></li>
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
@@ -18312,8 +18310,8 @@ image4    |300px| centre
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
                        <div class="thumb" style="height: 150px;">Image4</div>
                        <div class="gallerytext">
-<p>300px| centre
-</p>
+<pre>centre
+</pre>
                        </div>
                </div></li>
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
@@ -18372,7 +18370,7 @@ image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
                <li class="gallerybox" style="width: 105px"><div style="width: 105px">
                        <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
                        <div class="gallerytext">
-<p>Blabla|blabla.
+<p>blabla.
 </p>
                        </div>
                </div></li>