Merge "Remove $wgDisableUserGroupExpiry feature flag"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 6 May 2017 21:04:19 +0000 (21:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 6 May 2017 21:04:19 +0000 (21:04 +0000)
14 files changed:
HISTORY
includes/DefaultSettings.php
includes/SiteStats.php
includes/api/ApiQueryAllImages.php
includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryContributors.php
includes/api/ApiQueryUsers.php
includes/api/ApiUserrights.php
includes/specials/SpecialUserrights.php
includes/specials/pagers/ActiveUsersPager.php
includes/specials/pagers/ContribsPager.php
includes/specials/pagers/NewFilesPager.php
includes/specials/pagers/UsersPager.php
includes/user/UserGroupMembership.php

diff --git a/HISTORY b/HISTORY
index be90221..9259814 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -27,9 +27,6 @@ Change notes from older releases. For current info see RELEASE-NOTES-1.30.
   $wgNamespacesWithSubpages[NS_TEMPLATE] to false to keep the old behavior.
 * $wgRunJobsAsync is now false by default (T142751). This change only affects
   wikis with $wgJobRunRate > 0.
-* A temporary feature flag, $wgDisableUserGroupExpiry, is provided to disable
-  new features that rely on the schema changes to the user_groups table. This
-  feature flag will likely be removed before 1.29 is released.
 * (T158474) "Unknown user" has been added to $wgReservedUsernames.
 * (T156983) $wgRateLimitsExcludedIPs now accepts CIDR ranges as well as single IPs.
 * $wgDummyLanguageCodes is deprecated. Additional language code mappings may be
index 7c18fcc..f8d2d75 100644 (file)
@@ -5912,15 +5912,6 @@ $wgBotPasswordsCluster = false;
  */
 $wgBotPasswordsDatabase = false;
 
-/**
- * Whether to disable user group expiry. This is a transitional feature flag
- * in accordance with WMF schema change policy, and will be removed later
- * (hopefully before MW 1.29 release).
- *
- * @since 1.29
- */
-$wgDisableUserGroupExpiry = false;
-
 /** @} */ # end of user rights settings
 
 /************************************************************************//**
index ac5e49e..d253805 100644 (file)
@@ -194,7 +194,6 @@ class SiteStats {
                        wfMemcKey( 'SiteStats', 'groupcounts', $group ),
                        $cache::TTL_HOUR,
                        function ( $oldValue, &$ttl, array &$setOpts ) use ( $group ) {
-                               global $wgDisableUserGroupExpiry;
                                $dbr = wfGetDB( DB_REPLICA );
 
                                $setOpts += Database::getCacheSetOptions( $dbr );
@@ -204,9 +203,7 @@ class SiteStats {
                                        'COUNT(*)',
                                        [
                                                'ug_group' => $group,
-                                               $wgDisableUserGroupExpiry ?
-                                                       '1' :
-                                                       'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() )
+                                               'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() )
                                        ],
                                        __METHOD__
                                );
index daeedbe..250bee6 100644 (file)
@@ -205,9 +205,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
                                        [
                                                'ug_group' => User::getGroupsWithPermission( 'bot' ),
                                                'ug_user = img_user',
-                                               $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
-                                                       '1' :
-                                                       'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
+                                               'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
                                        ]
                                ] ] );
                                $groupCond = ( $params['filterbots'] == 'nobots' ? 'NULL' : 'NOT NULL' );
index 0f0b2af..fd95e17 100644 (file)
@@ -122,9 +122,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                                        [
                                                'ug1.ug_user=user_id',
                                                'ug1.ug_group' => $params['group'],
-                                               $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
-                                                       '1' :
-                                                       'ug1.ug_expiry IS NULL OR ug1.ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
+                                               'ug1.ug_expiry IS NULL OR ug1.ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
                                        ]
                                ]
                        ] );
@@ -147,9 +145,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                        $this->addJoinConds( [ 'ug1' => [ 'LEFT OUTER JOIN',
                                array_merge( [
                                        'ug1.ug_user=user_id',
-                                       $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
-                                               '1' :
-                                               'ug1.ug_expiry IS NULL OR ug1.ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
+                                       'ug1.ug_expiry IS NULL OR ug1.ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
                                ], $exclude )
                        ] ] );
                        $this->addWhere( 'ug1.ug_user IS NULL' );
@@ -165,9 +161,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                        $this->addFields( [ 'groups' =>
                                $db->buildGroupConcatField( '|', 'user_groups', 'ug_group', [
                                        'ug_user=user_id',
-                                       $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
-                                               '1' :
-                                               'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
+                                       'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
                                ] )
                        ] );
                }
index 183409d..693d954 100644 (file)
@@ -163,9 +163,7 @@ class ApiQueryContributors extends ApiQueryBase {
                                [
                                        'ug_user=rev_user',
                                        'ug_group' => $limitGroups,
-                                       $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
-                                               '1' :
-                                               'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
+                                       'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
                                ]
                        ] ] );
                        $this->addWhereIf( 'ug_user IS NULL', $excludeGroups );
index 4515f7f..a5d06c8 100644 (file)
@@ -172,10 +172,8 @@ class ApiQueryUsers extends ApiQueryBase {
                                $this->addJoinConds( [ 'user_groups' => [ 'INNER JOIN', 'ug_user=user_id' ] ] );
                                $this->addFields( [ 'user_name' ] );
                                $this->addFields( UserGroupMembership::selectFields() );
-                               if ( !$this->getConfig()->get( 'DisableUserGroupExpiry' ) ) {
-                                       $this->addWhere( 'ug_expiry IS NULL OR ug_expiry >= ' .
-                                               $db->addQuotes( $db->timestamp() ) );
-                               }
+                               $this->addWhere( 'ug_expiry IS NULL OR ug_expiry >= ' .
+                                       $db->addQuotes( $db->timestamp() ) );
                                $userGroupsRes = $this->select( __METHOD__ );
 
                                foreach ( $userGroupsRes as $row ) {
index d857e4a..2a364d9 100644 (file)
@@ -58,7 +58,7 @@ class ApiUserrights extends ApiBase {
                $params = $this->extractRequestParams();
 
                // Figure out expiry times from the input
-               // @todo Remove this isset check when removing $wgDisableUserGroupExpiry
+               // $params['expiry'] may not be set in subclasses
                if ( isset( $params['expiry'] ) ) {
                        $expiry = (array)$params['expiry'];
                } else {
index 127b530..002b47c 100644 (file)
@@ -215,7 +215,7 @@ class UserrightsPage extends SpecialPage {
         * @return bool
         */
        public function canProcessExpiries() {
-               return !$this->getConfig()->get( 'DisableUserGroupExpiry' );
+               return true;
        }
 
        /**
index 0d6f493..e2f4d4b 100644 (file)
@@ -101,9 +101,7 @@ class ActiveUsersPager extends UsersPager {
                        $tables[] = 'user_groups';
                        $conds[] = 'ug_user = user_id';
                        $conds['ug_group'] = $this->groups;
-                       if ( !$this->getConfig()->get( 'DisableUserGroupExpiry' ) ) {
-                               $conds[] = 'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() );
-                       }
+                       $conds[] = 'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() );
                }
                if ( $this->excludegroups !== [] ) {
                        foreach ( $this->excludegroups as $group ) {
@@ -111,9 +109,7 @@ class ActiveUsersPager extends UsersPager {
                                        'user_groups', '1', [
                                                'ug_user = user_id',
                                                'ug_group' => $group,
-                                               $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
-                                                       '1' :
-                                                       'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() )
+                                               'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() )
                                        ]
                                ) . ')';
                        }
index 1133625..7d303de 100644 (file)
@@ -228,10 +228,8 @@ class ContribsPager extends ReverseChronologicalPager {
                                        'LEFT JOIN', [
                                                'ug_user = rev_user',
                                                'ug_group' => $groupsWithBotPermission,
-                                               $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
-                                                       '1' :
-                                                       'ug_expiry IS NULL OR ug_expiry >= ' .
-                                                               $this->mDb->addQuotes( $this->mDb->timestamp() )
+                                               'ug_expiry IS NULL OR ug_expiry >= ' .
+                                                       $this->mDb->addQuotes( $this->mDb->timestamp() )
                                        ]
                                ];
                        }
index b781930..e2d9d42 100644 (file)
@@ -77,9 +77,7 @@ class NewFilesPager extends ReverseChronologicalPager {
                                        [
                                                'ug_group' => $groupsWithBotPermission,
                                                'ug_user = img_user',
-                                               $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
-                                                       '1' :
-                                                       'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() )
+                                               'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() )
                                        ]
                                ];
                        }
index d599599..9aef9ad 100644 (file)
@@ -112,9 +112,7 @@ class UsersPager extends AlphabeticPager {
 
                if ( $this->requestedGroup != '' ) {
                        $conds['ug_group'] = $this->requestedGroup;
-                       if ( !$this->getConfig()->get( 'DisableUserGroupExpiry' ) ) {
-                               $conds[] = 'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() );
-                       }
+                       $conds[] = 'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() );
                }
 
                if ( $this->requestedUser != '' ) {
index 81a4083..cf05df3 100644 (file)
@@ -49,11 +49,6 @@ class UserGroupMembership {
         * @param string|null $expiry Timestamp of expiry in TS_MW format, or null if no expiry
         */
        public function __construct( $userId = 0, $group = null, $expiry = null ) {
-               global $wgDisableUserGroupExpiry;
-               if ( $wgDisableUserGroupExpiry ) {
-                       $expiry = null;
-               }
-
                $this->userId = (int)$userId;
                $this->group = $group; // TODO throw on invalid group?
                $this->expiry = $expiry ?: null;
@@ -77,26 +72,15 @@ class UserGroupMembership {
         * @return string|null Timestamp of expiry in TS_MW format, or null if no expiry
         */
        public function getExpiry() {
-               global $wgDisableUserGroupExpiry;
-               if ( $wgDisableUserGroupExpiry ) {
-                       return null;
-               }
-
                return $this->expiry;
        }
 
        protected function initFromRow( $row ) {
-               global $wgDisableUserGroupExpiry;
-
                $this->userId = (int)$row->ug_user;
                $this->group = $row->ug_group;
-               if ( $wgDisableUserGroupExpiry ) {
-                       $this->expiry = null;
-               } else {
-                       $this->expiry = $row->ug_expiry === null ?
-                               null :
-                               wfTimestamp( TS_MW, $row->ug_expiry );
-               }
+               $this->expiry = $row->ug_expiry === null ?
+                       null :
+                       wfTimestamp( TS_MW, $row->ug_expiry );
        }
 
        /**
@@ -117,19 +101,11 @@ class UserGroupMembership {
         * @return array
         */
        public static function selectFields() {
-               global $wgDisableUserGroupExpiry;
-               if ( $wgDisableUserGroupExpiry ) {
-                       return [
-                               'ug_user',
-                               'ug_group',
-                       ];
-               } else {
-                       return [
-                               'ug_user',
-                               'ug_group',
-                               'ug_expiry',
-                       ];
-               }
+               return [
+                       'ug_user',
+                       'ug_group',
+                       'ug_expiry',
+               ];
        }
 
        /**
@@ -140,7 +116,6 @@ class UserGroupMembership {
         * @return bool Whether or not anything was deleted
         */
        public function delete( IDatabase $dbw = null ) {
-               global $wgDisableUserGroupExpiry;
                if ( wfReadOnly() ) {
                        return false;
                }
@@ -149,14 +124,10 @@ class UserGroupMembership {
                        $dbw = wfGetDB( DB_MASTER );
                }
 
-               if ( $wgDisableUserGroupExpiry ) {
-                       $dbw->delete( 'user_groups', $this->getDatabaseArray( $dbw ), __METHOD__ );
-               } else {
-                       $dbw->delete(
-                               'user_groups',
-                               [ 'ug_user' => $this->userId, 'ug_group' => $this->group ],
-                               __METHOD__ );
-               }
+               $dbw->delete(
+                       'user_groups',
+                       [ 'ug_user' => $this->userId, 'ug_group' => $this->group ],
+                       __METHOD__ );
                if ( !$dbw->affectedRows() ) {
                        return false;
                }
@@ -182,7 +153,6 @@ class UserGroupMembership {
         * @return bool Whether or not anything was inserted
         */
        public function insert( $allowUpdate = false, IDatabase $dbw = null ) {
-               global $wgDisableUserGroupExpiry;
                if ( $dbw === null ) {
                        $dbw = wfGetDB( DB_MASTER );
                }
@@ -206,7 +176,7 @@ class UserGroupMembership {
 
                // Don't collide with expired user group memberships
                // Do this after trying to insert, in order to avoid locking
-               if ( !$wgDisableUserGroupExpiry && !$affected ) {
+               if ( !$affected ) {
                        $conds = [
                                'ug_user' => $row['ug_user'],
                                'ug_group' => $row['ug_group'],
@@ -245,16 +215,11 @@ class UserGroupMembership {
         * @return array
         */
        protected function getDatabaseArray( IDatabase $db ) {
-               global $wgDisableUserGroupExpiry;
-
-               $a = [
+               return [
                        'ug_user' => $this->userId,
                        'ug_group' => $this->group,
+                       'ug_expiry' => $this->expiry ? $db->timestamp( $this->expiry ) : null,
                ];
-               if ( !$wgDisableUserGroupExpiry ) {
-                       $a['ug_expiry'] = $this->expiry ? $db->timestamp( $this->expiry ) : null;
-               }
-               return $a;
        }
 
        /**
@@ -262,8 +227,7 @@ class UserGroupMembership {
         * @return bool
         */
        public function isExpired() {
-               global $wgDisableUserGroupExpiry;
-               if ( $wgDisableUserGroupExpiry || !$this->expiry ) {
+               if ( !$this->expiry ) {
                        return false;
                } else {
                        return wfTimestampNow() > $this->expiry;
@@ -276,8 +240,7 @@ class UserGroupMembership {
         * @param IDatabase|null $dbw
         */
        public static function purgeExpired( IDatabase $dbw = null ) {
-               global $wgDisableUserGroupExpiry;
-               if ( $wgDisableUserGroupExpiry || wfReadOnly() ) {
+               if ( wfReadOnly() ) {
                        return;
                }