diff options
Diffstat (limited to 'www/wiki/extensions/Translate/scripts/translator-stats.php')
-rw-r--r-- | www/wiki/extensions/Translate/scripts/translator-stats.php | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/www/wiki/extensions/Translate/scripts/translator-stats.php b/www/wiki/extensions/Translate/scripts/translator-stats.php index 8c5f8634..1847f46d 100644 --- a/www/wiki/extensions/Translate/scripts/translator-stats.php +++ b/www/wiki/extensions/Translate/scripts/translator-stats.php @@ -3,7 +3,7 @@ * Script to gather translator stats. * * @author Niklas Laxström - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @file */ @@ -24,42 +24,50 @@ class TS extends Maintenance { } public function execute() { - $dbr = wfGetDB( DB_SLAVE ); + global $wgDisableUserGroupExpiry; + + $dbr = wfGetDB( DB_REPLICA ); $users = $dbr->select( - array( 'user', 'user_groups' ), - array( + [ 'user', 'user_groups' ], + [ 'user_name', 'user_registration', 'user_editcount', 'ug_group', - ), - array( + ], + [ 'user_registration is not null' - ), + ], __METHOD__, - array( + [ 'ORDER BY' => 'user_id ASC', - ), - array( - 'user_groups' => array( + ], + [ + 'user_groups' => [ 'LEFT JOIN', - array( 'user_id=ug_user', 'ug_group' => 'translator' ) - ) - ) + [ + 'user_id=ug_user', + 'ug_group' => 'translator', + ( isset( $wgDisableUserGroupExpiry ) && !$wgDisableUserGroupExpiry ) ? + 'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() ) : + '' + ] + ] + ] ); echo "username\tregistration ts\tedit count\tis translator?\tpromoted ts\tmethod\n"; $rejected = $dbr->select( - array( 'logging' ), - array( + [ 'logging' ], + [ 'log_title', 'log_timestamp', - ), - array( + ], + [ 'log_type' => 'translatorsandbox', 'log_action' => 'rejected', - ), + ], __METHOD__ ); @@ -70,20 +78,20 @@ class TS extends Maintenance { foreach ( $users as $u ) { $logs = $dbr->select( 'logging', - array( + [ 'log_type', 'log_action', 'log_timestamp', 'log_params', - ), - array( + ], + [ 'log_title' => $u->user_name, - 'log_type' => array( 'rights', 'translatorsandbox' ), - ), + 'log_type' => [ 'rights', 'translatorsandbox' ], + ], __METHOD__, - array( + [ 'ORDER BY' => 'log_id ASC', - ) + ] ); $promoted = null; @@ -94,9 +102,9 @@ class TS extends Maintenance { $method = 'sandbox'; break; } elseif ( $log->log_action === 'rights' ) { - wfSuppressWarnings(); + Wikimedia\suppressWarnings(); $data = unserialize( $log->log_params ); - wfRestoreWarnings(); + Wikimedia\restoreWarnings(); if ( $data === false ) { $lines = explode( "\n", $log->log_params ); if ( strpos( $lines[1], 'translator' ) !== false ) { @@ -119,5 +127,5 @@ class TS extends Maintenance { } } -$maintClass = 'TS'; +$maintClass = TS::class; require_once RUN_MAINTENANCE_IF_MAIN; |