|
10 | 10 | use MediaWiki\MediaWikiServices;
|
11 | 11 | use MediaWiki\Revision\RevisionRecord;
|
12 | 12 | use MediaWiki\Revision\RevisionStore;
|
| 13 | +use MediaWiki\User\UserOptionsLookup; |
13 | 14 | use MWTimestamp;
|
14 | 15 | use User;
|
15 | 16 | use Wikimedia\Rdbms\ILoadBalancer;
|
@@ -40,19 +41,27 @@ class AchievementRegister implements
|
40 | 41 | */
|
41 | 42 | private $revisionStore;
|
42 | 43 |
|
| 44 | + /** |
| 45 | + * @var UserOptionsLookup |
| 46 | + */ |
| 47 | + private $userOptionsLookup; |
| 48 | + |
43 | 49 | /**
|
44 | 50 | * @param Config $config
|
45 | 51 | * @param ILoadBalancer $DBLoadBalancer
|
46 | 52 | * @param RevisionStore $revisionStore
|
| 53 | + * @param UserOptionsLookup $userOptionsLookup |
47 | 54 | */
|
48 | 55 | public function __construct(
|
49 | 56 | Config $config,
|
50 | 57 | ILoadBalancer $DBLoadBalancer,
|
51 |
| - RevisionStore $revisionStore |
| 58 | + RevisionStore $revisionStore, |
| 59 | + UserOptionsLookup $userOptionsLookup |
52 | 60 | ) {
|
53 | 61 | $this->config = $config;
|
54 | 62 | $this->mDb = $DBLoadBalancer->getMaintenanceConnectionRef( DB_REPLICA );
|
55 | 63 | $this->revisionStore = $revisionStore;
|
| 64 | + $this->userOptionsLookup = $userOptionsLookup; |
56 | 65 | }
|
57 | 66 |
|
58 | 67 | private const WEEKDAYS = [
|
@@ -177,7 +186,7 @@ public function onUserSaveSettings( $user ) {
|
177 | 186 | if ( !$this->config->get( Constants::CONFIG_KEY_ENABLE_BETA_FEATURE ) ) {
|
178 | 187 | return;
|
179 | 188 | }
|
180 |
| - if ( $user->getOption( Constants::PREF_KEY_ACHIEVEMENT_ENABLE ) ) { |
| 189 | + if ( $this->userOptionsLookup->getOption( $user, Constants::PREF_KEY_ACHIEVEMENT_ENABLE ) ) { |
181 | 190 | Achievement::achieve( [
|
182 | 191 | 'key' => Constants::ACHV_KEY_ENABLE_ACHIEVEMENT_BADGES,
|
183 | 192 | 'user' => $user,
|
|
0 commit comments