Merge "Add SPARQL client to core"
[lhc/web/wiklou.git] / languages / Language.php
index fdf2d05..084a2e7 100644 (file)
@@ -2140,7 +2140,7 @@ class Language {
                        return $ts;
                }
 
-               MediaWiki\suppressWarnings(); // E_STRICT system time bitching
+               Wikimedia\suppressWarnings(); // E_STRICT system time bitching
                # Generate an adjusted date; take advantage of the fact that mktime
                # will normalize out-of-range values so we don't have to split $minDiff
                # into hours and minutes.
@@ -2153,7 +2153,7 @@ class Language {
                        (int)substr( $ts, 0, 4 ) ); # Year
 
                $date = date( 'YmdHis', $t );
-               MediaWiki\restoreWarnings();
+               Wikimedia\restoreWarnings();
 
                return $date;
        }
@@ -2605,9 +2605,9 @@ class Language {
                # *input* string. We just ignore those too.
                # REF: https://bugs.php.net/bug.php?id=37166
                # REF: https://phabricator.wikimedia.org/T18885
-               MediaWiki\suppressWarnings();
+               Wikimedia\suppressWarnings();
                $text = iconv( $in, $out . '//IGNORE', $string );
-               MediaWiki\restoreWarnings();
+               Wikimedia\restoreWarnings();
                return $text;
        }
 
@@ -3489,15 +3489,16 @@ class Language {
         * @return string
         */
        function truncate( $string, $length, $ellipsis = '...', $adjustLength = true ) {
+               # Check if there is no need to truncate
+               if ( strlen( $string ) <= abs( $length ) ) {
+                       return $string; // no need to truncate
+               }
                # Use the localized ellipsis character
                if ( $ellipsis == '...' ) {
                        $ellipsis = wfMessage( 'ellipsis' )->inLanguage( $this )->escaped();
                }
-               # Check if there is no need to truncate
                if ( $length == 0 ) {
                        return $ellipsis; // convention
-               } elseif ( strlen( $string ) <= abs( $length ) ) {
-                       return $string; // no need to truncate
                }
                $stringOriginal = $string;
                # If ellipsis length is >= $length then we can't apply $adjustLength