From: This, that and the other Date: Tue, 11 Apr 2017 02:32:02 +0000 (+1000) Subject: Remove $wgDisableUserGroupExpiry feature flag X-Git-Tag: 1.31.0-rc.0~3319^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=f8008a7cb81af0205771448f22a5261a8615f258;p=lhc%2Fweb%2Fwiklou.git Remove $wgDisableUserGroupExpiry feature flag This feature flag was added to comply with WMF's schema change policy. It is no longer needed now that the feature is enabled on WMF sites. External MW installations will run update.php or manually do DB updates as required before upgrading MW. Bug: T162517 Change-Id: I5b532d79fd1e8b178490cf2617499ae62967de2c --- diff --git a/HISTORY b/HISTORY index be90221143..9259814a9a 100644 --- 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 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 7c18fcc594..f8d2d75f6c 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 /************************************************************************//** diff --git a/includes/SiteStats.php b/includes/SiteStats.php index ac5e49e70e..d253805589 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -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__ ); diff --git a/includes/api/ApiQueryAllImages.php b/includes/api/ApiQueryAllImages.php index daeedbef6a..250bee667f 100644 --- a/includes/api/ApiQueryAllImages.php +++ b/includes/api/ApiQueryAllImages.php @@ -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' ); diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 0f0b2afaaa..fd95e1785a 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -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() ) ] ) ] ); } diff --git a/includes/api/ApiQueryContributors.php b/includes/api/ApiQueryContributors.php index 183409d24f..693d954d90 100644 --- a/includes/api/ApiQueryContributors.php +++ b/includes/api/ApiQueryContributors.php @@ -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 ); diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index 4515f7f606..a5d06c824c 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -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 ) { diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php index d857e4afdd..2a364d9756 100644 --- a/includes/api/ApiUserrights.php +++ b/includes/api/ApiUserrights.php @@ -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 { diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 127b530e0f..002b47cf7e 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -215,7 +215,7 @@ class UserrightsPage extends SpecialPage { * @return bool */ public function canProcessExpiries() { - return !$this->getConfig()->get( 'DisableUserGroupExpiry' ); + return true; } /** diff --git a/includes/specials/pagers/ActiveUsersPager.php b/includes/specials/pagers/ActiveUsersPager.php index 0d6f493d59..e2f4d4b57d 100644 --- a/includes/specials/pagers/ActiveUsersPager.php +++ b/includes/specials/pagers/ActiveUsersPager.php @@ -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() ) ] ) . ')'; } diff --git a/includes/specials/pagers/ContribsPager.php b/includes/specials/pagers/ContribsPager.php index 11336251ec..7d303de104 100644 --- a/includes/specials/pagers/ContribsPager.php +++ b/includes/specials/pagers/ContribsPager.php @@ -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() ) ] ]; } diff --git a/includes/specials/pagers/NewFilesPager.php b/includes/specials/pagers/NewFilesPager.php index b78193002a..e2d9d4201e 100644 --- a/includes/specials/pagers/NewFilesPager.php +++ b/includes/specials/pagers/NewFilesPager.php @@ -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() ) ] ]; } diff --git a/includes/specials/pagers/UsersPager.php b/includes/specials/pagers/UsersPager.php index d599599031..9aef9ade4b 100644 --- a/includes/specials/pagers/UsersPager.php +++ b/includes/specials/pagers/UsersPager.php @@ -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 != '' ) { diff --git a/includes/user/UserGroupMembership.php b/includes/user/UserGroupMembership.php index 81a4083bb4..cf05df331e 100644 --- a/includes/user/UserGroupMembership.php +++ b/includes/user/UserGroupMembership.php @@ -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; }