diff options
author | C. Scott Ananian <cscott@cscott.net> | 2018-06-13 13:49:29 -0400 |
---|---|---|
committer | C. Scott Ananian <cscott@cscott.net> | 2018-07-09 13:36:27 -0400 |
commit | 0935e47a721787c830e6d85ed59a3e4d4d58846c (patch) | |
tree | 256fbf2c68f09309bc8aadd4a7321e96cc4e4042 /includes/CommentStore.php | |
parent | 0ada062ce62a261e55eb2bfbe9c6f74ffbaa05e5 (diff) | |
download | mediawikicore-0935e47a721787c830e6d85ed59a3e4d4d58846c.tar.gz mediawikicore-0935e47a721787c830e6d85ed59a3e4d4d58846c.zip |
Remove most uses of deprecated Language::truncate()
The Language::truncate() function was split into
Language::truncateForVisual() (which measures characters) and
Language::truncateForDatabase() (which measures bytes) in 1.31, but
the patch which soft-deprecated Language::truncate() didn't actually
remove all the uses in the codebase. Replace most of those old uses
now, which should actually improve the situation for
non-latin-alphabet users who were getting unfairly squeezed in a
number of places.
Bug: T197492
Change-Id: I2291c69d9df17c1a9e4ab1b7d4cbc73bc51d3ebb
Diffstat (limited to 'includes/CommentStore.php')
-rw-r--r-- | includes/CommentStore.php | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/includes/CommentStore.php b/includes/CommentStore.php index 8a1901c747a5..484b8464dd15 100644 --- a/includes/CommentStore.php +++ b/includes/CommentStore.php @@ -458,16 +458,7 @@ class CommentStore { $comment = CommentStoreComment::newUnsavedComment( $comment, $data ); # Truncate comment in a Unicode-sensitive manner - $comment->text = $this->lang->truncate( $comment->text, self::MAX_COMMENT_LENGTH ); - if ( mb_strlen( $comment->text, 'UTF-8' ) > self::COMMENT_CHARACTER_LIMIT ) { - $ellipsis = wfMessage( 'ellipsis' )->inLanguage( $this->lang )->escaped(); - if ( mb_strlen( $ellipsis ) >= self::COMMENT_CHARACTER_LIMIT ) { - // WTF? - $ellipsis = '...'; - } - $maxLength = self::COMMENT_CHARACTER_LIMIT - mb_strlen( $ellipsis, 'UTF-8' ); - $comment->text = mb_substr( $comment->text, 0, $maxLength, 'UTF-8' ) . $ellipsis; - } + $comment->text = $this->lang->truncateForVisual( $comment->text, self::COMMENT_CHARACTER_LIMIT ); if ( $this->stage > MIGRATION_OLD && !$comment->id ) { $dbData = $comment->data; @@ -530,7 +521,7 @@ class CommentStore { $comment = $this->createComment( $dbw, $comment, $data ); if ( $this->stage <= MIGRATION_WRITE_BOTH ) { - $fields[$key] = $this->lang->truncate( $comment->text, 255 ); + $fields[$key] = $this->lang->truncateForDatabase( $comment->text, 255 ); } if ( $this->stage >= MIGRATION_WRITE_BOTH ) { |