diff options
Diffstat (limited to 'MLEB/Translate/utils/MessageGroupStats.php')
-rw-r--r-- | MLEB/Translate/utils/MessageGroupStats.php | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/MLEB/Translate/utils/MessageGroupStats.php b/MLEB/Translate/utils/MessageGroupStats.php index 91267f22..dc7b1133 100644 --- a/MLEB/Translate/utils/MessageGroupStats.php +++ b/MLEB/Translate/utils/MessageGroupStats.php @@ -8,6 +8,7 @@ * @license GPL-2.0-or-later */ +use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use Wikimedia\Rdbms\IDatabase; @@ -34,14 +35,9 @@ class MessageGroupStats { /// Do not defer updates. Meant for jobs like MessageGroupStatsRebuildJob. public const FLAG_IMMEDIATE_WRITES = 4; - /** - * @var array[] - */ + /** @var array[] */ protected static $updates = []; - - /** - * @var string[] - */ + /** @var string[] */ private static $languages; /** @@ -547,9 +543,7 @@ class MessageGroupStats { if ( $code === $wgTranslateDocumentationLanguageCode ) { $ffs = $group->getFFS(); if ( $ffs instanceof GettextFFS ) { - /** - * @var FileBasedMessageGroup $group - */ + /** @var FileBasedMessageGroup $group */ '@phan-var FileBasedMessageGroup $group'; $cache = $group->getMessageGroupCache( $group->getSourceLanguage() ); if ( $cache->exists() ) { @@ -566,7 +560,7 @@ class MessageGroupStats { } $collection->filter( 'ignored' ); - $collection->filter( 'optional' ); + $collection->filterUntranslatedOptional(); // Store the count of real messages for later calculation. $total = count( $collection ); @@ -626,6 +620,18 @@ class MessageGroupStats { return; } + // This path should only be hit during web requests + if ( count( $updates ) > 100 ) { + $groups = array_unique( array_column( $updates, 'tgs_group' ) ); + LoggerFactory::getInstance( 'Translate' )->warning( + "Huge translation update of {count} rows for group(s) {groups}", + [ + 'count' => count( $updates ), + 'groups' => implode( ', ', $groups ), + ] + ); + } + $primaryKey = [ 'tgs_group', 'tgs_lang' ]; $dbw->replace( $table, [ $primaryKey ], $updates, $method ); $updates = []; |