Use LogPage::validTypes() instead of $wgLogTypes in a few places
authorKunal Mehta <legoktm@member.fsf.org>
Wed, 25 Jul 2018 23:40:47 +0000 (16:40 -0700)
committerKrinkle <krinklemail@gmail.com>
Sat, 28 Jul 2018 19:09:08 +0000 (19:09 +0000)
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
includes/api/ApiQueryLogEvents.php
includes/specials/SpecialLog.php
maintenance/rebuildrecentchanges.php

index a3fdcfc..03dbfb9 100644 (file)
@@ -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 = [
        '',
index 8fd1ed5..a6b97dd 100644 (file)
@@ -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()
index 359eede..2160312 100644 (file)
@@ -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 ) {
index a259484..d86c8ed 100644 (file)
@@ -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' ],