r84662 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84661‎ | r84662 | r84663 >
Date:03:39, 24 March 2011
Author:bawolff
Status:ok
Tags:
Comment:
(follow-up r84660) Per comments, make truncate return original string instead of ellipsis if string is smaller then length and ellipsis is not.
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -2395,10 +2395,15 @@
23962396 }
23972397 $eLength = $adjustLength ? strlen( $ellipsis ) : 0;
23982398 # Check if there is no need to truncate
2399 - if ( $length == 0 || strlen( $ellipsis ) >= abs( $length ) ) {
 2399+ if ( $length == 0 ) {
24002400 return $ellipsis;
24012401 } elseif ( strlen( $string ) <= abs( $length ) ) {
24022402 return $string;
 2403+ } elseif ( strlen( $ellipsis ) >= abs( $length ) ) {
 2404+ // Not combined with first (length == 0) if statement, since
 2405+ // we want to return the string instead of ellipsis if both
 2406+ // this and the proceeding elseif are true.
 2407+ return $ellipsis;
24032408 }
24042409 $stringOriginal = $string;
24052410 if ( $length > 0 ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84660(follow-up 79778) Make $wgLang->truncate function consider the length of the ...bawolff02:54, 24 March 2011

Status & tagging log