From c96accbb60f93a4212d9c664637a92176259666f Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 25 Jul 2018 16:40:47 -0700 Subject: [PATCH] Use LogPage::validTypes() instead of $wgLogTypes in a few places This is preparation for T200385, which will add a hook to modify the list of known log types, which will bypass the global variable. Change-Id: I763cf8b71a98d1dba5f9964fc8d919a268c5d8a5 --- includes/DefaultSettings.php | 3 +++ includes/api/ApiQueryLogEvents.php | 2 +- includes/specials/SpecialLog.php | 4 ++-- maintenance/rebuildrecentchanges.php | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index a3fdcfc2f9..03dbfb9c18 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -7745,6 +7745,9 @@ $wgCategoryCollation = 'uppercase'; * general category and can be viewed as a named subset of all logs; and * an action, which is a specific kind of event that can exist in that * log type. + * + * Note that code should call LogPage::validTypes() to get a list of valid + * log types instead of checking the global variable. */ $wgLogTypes = [ '', diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index 8fd1ed5ca9..a6b97dd895 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -418,7 +418,7 @@ class ApiQueryLogEvents extends ApiQueryBase { ApiBase::PARAM_HELP_MSG_PER_VALUE => [], ], 'type' => [ - ApiBase::PARAM_TYPE => $config->get( 'LogTypes' ) + ApiBase::PARAM_TYPE => LogPage::validTypes(), ], 'action' => [ // validation on request is done in execute() diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php index 359eedea78..216031295a 100644 --- a/includes/specials/SpecialLog.php +++ b/includes/specials/SpecialLog.php @@ -176,7 +176,7 @@ class SpecialLog extends SpecialPage { * @return string[] subpages */ public function getSubpagesForPrefixSearch() { - $subpages = $this->getConfig()->get( 'LogTypes' ); + $subpages = LogPage::validTypes(); $subpages[] = 'all'; sort( $subpages ); return $subpages; @@ -198,7 +198,7 @@ class SpecialLog extends SpecialPage { $parms = explode( '/', $par ); $symsForAll = [ '*', 'all' ]; if ( $parms[0] != '' && - ( in_array( $par, $this->getConfig()->get( 'LogTypes' ) ) || in_array( $par, $symsForAll ) ) + ( in_array( $par, LogPage::validTypes() ) || in_array( $par, $symsForAll ) ) ) { $opts->setValue( 'type', $par ); } elseif ( count( $parms ) == 2 ) { diff --git a/maintenance/rebuildrecentchanges.php b/maintenance/rebuildrecentchanges.php index a259484f7f..d86c8ed0f2 100644 --- a/maintenance/rebuildrecentchanges.php +++ b/maintenance/rebuildrecentchanges.php @@ -269,7 +269,7 @@ class RebuildRecentchanges extends Maintenance { * Rebuild pass 3: Insert `recentchanges` entries for action logs. */ private function rebuildRecentChangesTablePass3( ILBFactory $lbFactory ) { - global $wgLogTypes, $wgLogRestrictions; + global $wgLogRestrictions; $dbw = $this->getDB( DB_MASTER ); $commentStore = CommentStore::getStore(); @@ -296,7 +296,7 @@ class RebuildRecentchanges extends Maintenance { 'log_timestamp < ' . $dbw->addQuotes( $dbw->timestamp( $this->cutoffTo ) ), // Some logs don't go in RC since they are private. // @FIXME: core/extensions also have spammy logs that don't go in RC. - 'log_type' => array_diff( $wgLogTypes, array_keys( $wgLogRestrictions ) ), + 'log_type' => array_diff( LogPage::validTypes(), array_keys( $wgLogRestrictions ) ), ], __METHOD__, [ 'ORDER BY' => 'log_timestamp DESC' ], -- 2.20.1