diff options
Diffstat (limited to 'MLEB/Translate/specials/SpecialLanguageStats.php')
-rw-r--r-- | MLEB/Translate/specials/SpecialLanguageStats.php | 87 |
1 files changed, 38 insertions, 49 deletions
diff --git a/MLEB/Translate/specials/SpecialLanguageStats.php b/MLEB/Translate/specials/SpecialLanguageStats.php index 161b9683..62aa3f79 100644 --- a/MLEB/Translate/specials/SpecialLanguageStats.php +++ b/MLEB/Translate/specials/SpecialLanguageStats.php @@ -20,56 +20,43 @@ * @ingroup SpecialPage TranslateSpecialPage Stats */ class SpecialLanguageStats extends SpecialPage { - /** - * @var StatsTable - */ + /** @var StatsTable */ protected $table; - - /** - * @var Array - */ + /** @var array */ protected $targetValueName = [ 'code', 'language' ]; - /** * Most of the displayed numbers added together at the bottom of the table. */ protected $totals; - /** * Flag to set if nothing to show. * @var bool */ protected $nothing = false; - /** * Flag to set if not all numbers are available. * @var bool */ protected $incomplete = false; - /** * Whether to hide rows which are fully translated. * @var bool */ protected $noComplete = true; - /** * Whether to hide rows which are fully untranslated. * @var bool */ protected $noEmpty = false; - /** * The target of stats, language code or group id. */ protected $target; - /** * Whether to regenerate stats. Activated by action=purge in query params. * @var bool */ protected $purge; - /** * Helper variable to avoid overcounting message groups that appear * multiple times in the list with different parents. Aggregate message @@ -78,10 +65,7 @@ class SpecialLanguageStats extends SpecialPage { * @var array */ protected $statsCounted = []; - - /** - * @var array - */ + /** @var array */ protected $states; public function __construct() { @@ -472,7 +456,7 @@ class SpecialLanguageStats extends SpecialPage { /** * Actually creates the table for single message group, unless it - * is blacklisted or hidden by filters. + * is in the exclusion list or hidden by filters. * @param MessageGroup $group * @param array $cache * @param MessageGroup|null $parent @@ -483,7 +467,7 @@ class SpecialLanguageStats extends SpecialPage { ) { $groupId = $group->getId(); - if ( $this->table->isBlacklisted( $groupId, $this->target ) !== null ) { + if ( $this->table->isExcluded( $groupId, $this->target ) !== null ) { return ''; } @@ -521,35 +505,40 @@ class SpecialLanguageStats extends SpecialPage { $params[] = $this->getLanguage()->getCode(); $params[] = md5( $this->target ); $params[] = $parent ? $parent->getId() : '!'; - $cachekey = wfMemcKey( __METHOD__ . '-v3', implode( '-', $params ) ); - $cacheval = wfGetCache( CACHE_ANYTHING )->get( $cachekey ); - if ( is_string( $cacheval ) ) { - return $cacheval; - } - // Any data variable read below should be part of the cache key above - $extra = []; - if ( $translated === $total ) { - $extra = [ 'action' => 'proofread' ]; - } - - $rowParams = []; - $rowParams['data-groupid'] = $groupId; - $rowParams['class'] = get_class( $group ); - if ( $parent ) { - $rowParams['data-parentgroup'] = $parent->getId(); - } - - $out = "\t" . Html::openElement( 'tr', $rowParams ); - $out .= "\n\t\t" . Html::rawElement( 'td', [], - $this->table->makeGroupLink( $group, $this->target, $extra ) ); - $out .= $this->table->makeNumberColumns( $stats ); - $out .= $this->getWorkflowStateCell( $groupId, $state ); - $out .= "\n\t" . Html::closeElement( 'tr' ) . "\n"; - - wfGetCache( CACHE_ANYTHING )->set( $cachekey, $out, 3600 * 24 ); - - return $out; + $cache = ObjectCache::getInstance( CACHE_ANYTHING ); + + return $cache->getWithSetCallback( + $cache->makeKey( __METHOD__ . '-v3', implode( '-', $params ) ), + $cache::TTL_DAY, + function () use ( $translated, $total, $groupId, $group, $parent, $stats, $state ) { + // Any data variable read below should be part of the cache key above + $extra = []; + if ( $translated === $total ) { + $extra = [ 'action' => 'proofread' ]; + } + + $rowParams = []; + $rowParams['data-groupid'] = $groupId; + $rowParams['class'] = get_class( $group ); + if ( $parent ) { + $rowParams['data-parentgroup'] = $parent->getId(); + } + + return "\t" . + Html::openElement( 'tr', $rowParams ) . + "\n\t\t" . + Html::rawElement( + 'td', + [], + $this->table->makeGroupLink( $group, $this->target, $extra ) + ) . $this->table->makeNumberColumns( $stats ) . + $this->getWorkflowStateCell( $groupId, $state ) . + "\n\t" . + Html::closeElement( 'tr' ) . + "\n"; + } + ); } protected function getWorkflowStates( $field = 'tgr_group', $filter = 'tgr_lang' ) { |