jenkins-bot has submitted this change and it was merged.
Change subject: Allow preferences to be exempted from auto-enroll
......................................................................
Allow preferences to be exempted from auto-enroll
- Setting `exempt-from-auto-enrollment => true` in
preference definition object will prevent auto
enrollment despite auto-enroll and auto-enroll-group.
Bug: T114266
Change-Id: I668a7e65b541dc9dbd8d13fa2cfc467c5d14450a
---
M BetaFeaturesHooks.php
M tests/AutoEnrollmentTest.php
2 files changed, 19 insertions(+), 1 deletion(-)
Approvals:
Mattflaschen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/BetaFeaturesHooks.php b/BetaFeaturesHooks.php
index f9bb6e1..3b3b835 100644
--- a/BetaFeaturesHooks.php
+++ b/BetaFeaturesHooks.php
@@ -219,7 +219,8 @@
$user->getOption(
$autoEnroll[$info['group']] ) === HTMLFeatureField::OPTION_ENABLED;
}
- $autoEnrollHere = $autoEnrollAll === true ||
$autoEnrollForThisPref === true;
+ $exemptAutoEnroll = isset(
$info['exempt-from-auto-enrollment'] ) && $info['exempt-from-auto-enrollment']
=== true;
+ $autoEnrollHere = !$exemptAutoEnroll && (
$autoEnrollAll === true || $autoEnrollForThisPref === true );
if ( $currentValue !== HTMLFeatureField::OPTION_ENABLED
&&
$currentValue !==
HTMLFeatureField::OPTION_DISABLED &&
diff --git a/tests/AutoEnrollmentTest.php b/tests/AutoEnrollmentTest.php
index f428129..f81b2da 100644
--- a/tests/AutoEnrollmentTest.php
+++ b/tests/AutoEnrollmentTest.php
@@ -51,6 +51,15 @@
'discussion-link' => 'http://example.org/feedback/two',
'group' => 'unittest2',
),
+
+ 'unittest-ft3' => array(
+ 'label-message' => 'something entirely different',
+ 'desc-message' => 'something entirely differenter',
+ 'info-link' => 'http://example.org/feature/three',
+ 'discussion-link' =>
'http://example.org/feedback/three',
+ 'group' => 'unittest2',
+ 'exempt-from-auto-enrollment' => true,
+ ),
);
static function hookThatRegistersPreference( $user, &$betaPrefs ) {
@@ -118,6 +127,14 @@
HTMLFeatureField::OPTION_ENABLED,
'Hooks did not set the preference though global
auto-enroll was set.',
),
+
+ array(
+ 'betafeatures-auto-enroll',
+ HTMLFeatureField::OPTION_ENABLED,
+ 'unittest-ft3',
+ null,
+ 'The preferences was not set despite
auto-enroll because it is exempt-from-auto-enrollment.',
+ ),
);
}
--
To view, visit https://gerrit.wikimedia.org/r/242714
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I668a7e65b541dc9dbd8d13fa2cfc467c5d14450a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/BetaFeatures
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits