X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Forphans.php;h=d47ca43f0bead79c5bcfaeeea01f5334be17b949;hb=65a7696952de8cf9f2ef0cca1e79b12f23813b06;hp=7acf6d8279dc41496cd06f3b040b251f2128e454;hpb=a7e2b91b2c72f3522a7a9c3c957a43309e70b92e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/orphans.php b/maintenance/orphans.php index 7acf6d8279..d47ca43f0b 100644 --- a/maintenance/orphans.php +++ b/maintenance/orphans.php @@ -30,6 +30,7 @@ require_once __DIR__ . '/Maintenance.php'; +use MediaWiki\MediaWikiServices; use Wikimedia\Rdbms\IMaintainableDatabase; /** @@ -97,24 +98,30 @@ class Orphans extends Maintenance { ); $orphans = $result->numRows(); if ( $orphans > 0 ) { - global $wgContLang; - $this->output( "$orphans orphan revisions...\n" ); $this->output( sprintf( "%10s %10s %14s %20s %s\n", 'rev_id', 'rev_page', 'rev_timestamp', 'rev_user_text', 'rev_comment' ) ); + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); foreach ( $result as $row ) { $comment = $commentStore->getComment( 'rev_comment', $row )->text; if ( $comment !== '' ) { - $comment = '(' . $wgContLang->truncate( $comment, 40 ) . ')'; + $comment = '(' . $contLang->truncateForVisual( $comment, 40 ) . ')'; + } + $rev_user_text = $contLang->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 %20s %s\n", + $this->output( sprintf( "%10d %10d %14s %s %s\n", $row->rev_id, $row->rev_page, $row->rev_timestamp, - $wgContLang->truncate( $row->rev_user_text, 17 ), + $rev_user_text, $comment ) ); if ( $fix ) { $dbw->delete( 'revision', [ 'rev_id' => $row->rev_id ] );