From ae8e8bcdd0c00ff6d862eaf6e3473c055f4ae54a Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Fri, 29 Jan 2010 13:39:06 +0000 Subject: [PATCH] * (bug 22181) Do not truncate if the ellipsis actually make the string longer --- RELEASE-NOTES | 1 + languages/Language.php | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6cd34ecf1c..c0ccb2bd0a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/languages/Language.php b/languages/Language.php index 8c072f81c8..facd0edee6 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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; + } } } -- 2.20.1