Follow-up to I2291c69d9df17c1a9e4ab1b7d4cbc73bc51d3ebb -- this code uses
sprintf to align text, which won't really work for multibyte UTF8 or
unicode combining characters. Alas. Do the best we can for now.
Bug: T197492
Change-Id: Iaa4d7bd64588ca1f215921339d84f960380ae12b
foreach ( $result as $row ) {
$comment = $commentStore->getComment( 'rev_comment', $row )->text;
if ( $comment !== '' ) {
foreach ( $result as $row ) {
$comment = $commentStore->getComment( 'rev_comment', $row )->text;
if ( $comment !== '' ) {
- $comment = '(' . $wgContLang->truncate( $comment, 40 ) . ')';
+ $comment = '(' . $wgContLang->truncateForVisual( $comment, 40 ) . ')';
- $this->output( sprintf( "%10d %10d %14s %20s %s\n",
+ $rev_user_text = $wgContLang->truncateForVisual( $row->rev_user_text, 20 );
+ # pad $rev_user_text to 20 characters. Note that this may
+ # yield poor results if $rev_user_text contains combining
+ # or half-width characters. Alas.
+ if ( mb_strlen( $rev_user_text ) < 20 ) {
+ $rev_user_text = str_repeat( ' ', 20 - mb_strlen( $rev_user_text ) );
+ }
+ $this->output( sprintf( "%10d %10d %14s %s %s\n",
$row->rev_id,
$row->rev_page,
$row->rev_timestamp,
$row->rev_id,
$row->rev_page,
$row->rev_timestamp,
- $wgContLang->truncate( $row->rev_user_text, 17 ),
$comment ) );
if ( $fix ) {
$dbw->delete( 'revision', [ 'rev_id' => $row->rev_id ] );
$comment ) );
if ( $fix ) {
$dbw->delete( 'revision', [ 'rev_id' => $row->rev_id ] );