mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CookieWarning
synced 2024-11-27 15:40:16 +00:00
Avoid using User::getBoolOption()
User::getBoolOption() is deprecated and should be replaced with UserOptionsLookup::getBoolOption() Bug: T277600 Change-Id: I562b19ca41a7ef18be940ec398d58d6873b2555b
This commit is contained in:
parent
72c69e644a
commit
7e23848ac9
|
@ -5,6 +5,7 @@ namespace CookieWarning;
|
|||
use Config;
|
||||
use ConfigException;
|
||||
use IContextSource;
|
||||
use MediaWiki\User\UserOptionsLookup;
|
||||
use MWException;
|
||||
use WANObjectCache;
|
||||
|
||||
|
@ -12,6 +13,7 @@ class Decisions {
|
|||
private $config;
|
||||
private $geoLocation;
|
||||
private $cache;
|
||||
private $userOptionsLookup;
|
||||
|
||||
private const CACHE_KEY = 'cookieWarningIpLookupCache:';
|
||||
|
||||
|
@ -19,11 +21,18 @@ class Decisions {
|
|||
* @param Config $config
|
||||
* @param GeoLocation $geoLocation
|
||||
* @param WANObjectCache $cache
|
||||
* @param UserOptionsLookup $userOptionsLookup
|
||||
*/
|
||||
public function __construct( Config $config, GeoLocation $geoLocation, WANObjectCache $cache ) {
|
||||
public function __construct(
|
||||
Config $config,
|
||||
GeoLocation $geoLocation,
|
||||
WANObjectCache $cache,
|
||||
UserOptionsLookup $userOptionsLookup
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->geoLocation = $geoLocation;
|
||||
$this->cache = $cache;
|
||||
$this->userOptionsLookup = $userOptionsLookup;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +48,7 @@ class Decisions {
|
|||
$user = $context->getUser();
|
||||
|
||||
return $this->config->get( 'CookieWarningEnabled' ) &&
|
||||
!$user->getBoolOption( 'cookiewarning_dismissed', false ) &&
|
||||
!$this->userOptionsLookup->getBoolOption( $user, 'cookiewarning_dismissed' ) &&
|
||||
!$context->getRequest()->getCookie( 'cookiewarning_dismissed' ) &&
|
||||
( $this->config->get( 'CookieWarningGeoIPLookup' ) === 'js' ||
|
||||
$this->isInConfiguredRegion( $context ) );
|
||||
|
|
|
@ -21,7 +21,11 @@ return [
|
|||
return new HttpGeoLocation( $geoIPServiceURL );
|
||||
},
|
||||
'CookieWarning.Decisions' => function ( MediaWikiServices $services ) {
|
||||
return new Decisions( $services->getService( 'CookieWarning.Config' ),
|
||||
$services->getService( 'GeoLocation' ), $services->getMainWANObjectCache() );
|
||||
return new Decisions(
|
||||
$services->getService( 'CookieWarning.Config' ),
|
||||
$services->getService( 'GeoLocation' ),
|
||||
$services->getMainWANObjectCache(),
|
||||
$services->getUserOptionsLookup()
|
||||
);
|
||||
},
|
||||
];
|
||||
|
|
|
@ -34,7 +34,8 @@ class DecisionsTest extends MediaWikiTestCase {
|
|||
$cookieWarningDecisions = new Decisions(
|
||||
MediaWikiServices::getInstance()->getService( 'CookieWarning.Config' ),
|
||||
$geoLocation,
|
||||
new WANObjectCache( [ 'cache' => new HashBagOStuff() ] )
|
||||
new WANObjectCache( [ 'cache' => new HashBagOStuff() ] ),
|
||||
MediaWikiServices::getInstance()->getUserOptionsLookup()
|
||||
);
|
||||
|
||||
$cookieWarningDecisions->shouldShowCookieWarning( RequestContext::getMain() );
|
||||
|
|
Loading…
Reference in a new issue