X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Factions%2FInfoAction.php;h=0a4eae87815708d2446cd69c1afd846d799e0258;hb=242a76d2be99b205083761270ff8dbd03448c524;hp=3d3340600b918c14637ed303d8d1139dfd79de9c;hpb=a79d012e1c40dbeeb55a90b8099fea4aa9b1270b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 3d3340600b..0a4eae8781 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -195,9 +195,14 @@ class InfoAction extends FormlessAction { } /** - * Returns page information in an easily-manipulated format. Array keys are used so extensions - * may add additional information in arbitrary positions. Array values are arrays with one - * element to be rendered as a header, arrays with two elements to be rendered as a table row. + * Returns an array of info groups (will be rendered as tables), keyed by group ID. + * Group IDs are arbitrary and used so that extensions may add additional information in + * arbitrary positions (and as message keys for section headers for the tables, prefixed + * with 'pageinfo-'). + * Each info group is a non-associative array of info items (rendered as table rows). + * Each info item is an array with two elements: the first describes the type of + * information, the second the value for the current page. Both can be strings (will be + * interpreted as raw HTML) or messages (will be interpreted as plain text and escaped). * * @return array */ @@ -441,7 +446,8 @@ class InfoAction extends FormlessAction { if ( $title->inNamespace( NS_FILE ) ) { $fileObj = wfFindFile( $title ); if ( $fileObj !== false ) { - $output = $fileObj->getSha1(); + // Convert the base-36 sha1 value obtained from database to base-16 + $output = Wikimedia\base_convert( $fileObj->getSha1(), 36, 16, 40 ); $pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-file-hash' ), $output @@ -717,6 +723,8 @@ class InfoAction extends FormlessAction { self::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ), WANObjectCache::TTL_WEEK, function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) { + global $wgActorTableSchemaMigrationStage; + $title = $page->getTitle(); $id = $title->getArticleID(); @@ -724,6 +732,29 @@ class InfoAction extends FormlessAction { $dbrWatchlist = wfGetDB( DB_REPLICA, 'watchlist' ); $setOpts += Database::getCacheSetOptions( $dbr, $dbrWatchlist ); + if ( $wgActorTableSchemaMigrationStage === MIGRATION_NEW ) { + $tables = [ 'revision_actor_temp' ]; + $field = 'revactor_actor'; + $pageField = 'revactor_page'; + $tsField = 'revactor_timestamp'; + $joins = []; + } elseif ( $wgActorTableSchemaMigrationStage === MIGRATION_OLD ) { + $tables = [ 'revision' ]; + $field = 'rev_user_text'; + $pageField = 'rev_page'; + $tsField = 'rev_timestamp'; + $joins = []; + } else { + $tables = [ 'revision', 'revision_actor_temp', 'actor' ]; + $field = 'COALESCE( actor_name, rev_user_text)'; + $pageField = 'rev_page'; + $tsField = 'rev_timestamp'; + $joins = [ + 'revision_actor_temp' => [ 'LEFT JOIN', 'revactor_rev = rev_id' ], + 'actor' => [ 'LEFT JOIN', 'revactor_actor = actor_id' ], + ]; + } + $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore(); $result = []; @@ -751,10 +782,12 @@ class InfoAction extends FormlessAction { $result['authors'] = 0; } else { $result['authors'] = (int)$dbr->selectField( - 'revision', - 'COUNT(DISTINCT rev_user_text)', - [ 'rev_page' => $id ], - $fname + $tables, + "COUNT(DISTINCT $field)", + [ $pageField => $id ], + $fname, + [], + $joins ); } @@ -775,13 +808,15 @@ class InfoAction extends FormlessAction { // Recent number of distinct authors $result['recent_authors'] = (int)$dbr->selectField( - 'revision', - 'COUNT(DISTINCT rev_user_text)', + $tables, + "COUNT(DISTINCT $field)", [ - 'rev_page' => $id, - "rev_timestamp >= " . $dbr->addQuotes( $threshold ) + $pageField => $id, + "$tsField >= " . $dbr->addQuotes( $threshold ) ], - $fname + $fname, + [], + $joins ); // Subpages (if enabled)