* (bug 22181) Do not truncate if the ellipsis actually make the string longer
authorRaimond Spekking <raymond@users.mediawiki.org>
Fri, 29 Jan 2010 13:39:06 +0000 (13:39 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Fri, 29 Jan 2010 13:39:06 +0000 (13:39 +0000)
RELEASE-NOTES
languages/Language.php

index 6cd34ec..c0ccb2b 100644 (file)
@@ -724,6 +724,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   and Chick skins
 * Fixed bug involving unclosed "-{" markup in the language converter
 * (bug 21870) No longer include Google logo from an external server on wiki error.
+* (bug 22181) Do not truncate if the ellipsis actually make the string longer
 
 == API changes in 1.16 ==
 
index 8c072f8..facd0ed 100644 (file)
@@ -2153,6 +2153,7 @@ class Language {
                if ( strlen( $string ) <= abs( $length ) ) {
                        return $string;
                }
+               $stringOriginal = $string;
                if( $length > 0 ) {
                        $string = substr( $string, 0, $length );
                        $char = ord( $string[strlen( $string ) - 1] );
@@ -2166,7 +2167,13 @@ class Language {
                                # We chopped in the middle of a character; remove it
                                $string = $m[1];
                        }
-                       return $string . $ellipsis;
+                       # Do not truncate if the ellipsis actually make the string longer. Bug 22181
+                       if ( strlen( $string ) + strlen( $ellipsis ) < strlen( $stringOriginal ) ) {
+                               return $string . $ellipsis;
+                       } else {
+                               return $stringOriginal;
+                       }
+
                } else {
                        $string = substr( $string, $length );
                        $char = ord( $string[0] );
@@ -2174,7 +2181,12 @@ class Language {
                                # We chopped in the middle of a character; remove the whole thing
                                $string = preg_replace( '/^[\x80-\xbf]+/', '', $string );
                        }
-                       return $ellipsis . $string;
+                       # Do not truncate if the ellipsis actually make the string longer. Bug 22181
+                       if ( strlen( $string ) + strlen( $ellipsis ) < strlen( $stringOriginal ) ) {
+                               return $ellipsis . $string;
+                       } else {
+                               return $stringOriginal;
+                       }
                }
        }