From: This, that and the other Date: Tue, 25 Apr 2017 03:55:26 +0000 (+1000) Subject: Expire the cache of a User object when a group membership is set to expire X-Git-Tag: 1.31.0-rc.0~3406^2 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=9ee4e74e3174b8abab063008ebc7e4fce1bdcd41;p=lhc%2Fweb%2Fwiklou.git Expire the cache of a User object when a group membership is set to expire To avoid user permissions persisting for up to 1 hour beyond their expiry time. Bug: T163691 Change-Id: I85b578e6b7816639c3d0101d66efb1efedb17af6 --- diff --git a/includes/user/User.php b/includes/user/User.php index b8a36b8601..3edd49f783 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -509,6 +509,17 @@ class User implements IDBAccessObject { $ttl = $cache->adaptiveTTL( wfTimestamp( TS_UNIX, $this->mTouched ), $ttl ); + // if a user group membership is about to expire, the cache needs to + // expire at that time (T163691) + foreach ( $this->mGroupMemberships as $ugm ) { + if ( $ugm->getExpiry() ) { + $secondsUntilExpiry = wfTimestamp( TS_UNIX, $ugm->getExpiry() ) - time(); + if ( $secondsUntilExpiry > 0 && $secondsUntilExpiry < $ttl ) { + $ttl = $secondsUntilExpiry; + } + } + } + return $data; },