Catrope has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/350316 )

Change subject: Follow-up c047cd54d69ed: rename oresDamagingPref values back
......................................................................

Follow-up c047cd54d69ed: rename oresDamagingPref values back

Dealing with renamed preference values is going to be annoying,
especially in the config setting the default values. For now,
it's easier to unbreak things by renaming the preference values
back to hard/soft/softest and remapping them internally.

Bug: T160575
Change-Id: I228a636abea77548af16a830a8882b3327edc175
---
M extension.json
M includes/Hooks.php
2 files changed, 11 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES 
refs/changes/16/350316/1

diff --git a/extension.json b/extension.json
index b83636f..a8fa853 100644
--- a/extension.json
+++ b/extension.json
@@ -161,7 +161,7 @@
        },
        "DefaultUserOptions": {
                "ores-damaging-flag-rc": false,
-               "oresDamagingPref": "likelybad",
+               "oresDamagingPref": "hard",
                "oresHighlight": false,
                "oresRCHideNonDamaging": false,
                "oresWatchlistHideNonDamaging": false
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 859f7f6..bd6384e 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -30,6 +30,12 @@
 use Xml;
 
 class Hooks {
+       // The oresDamagingPref preference uses these names for historical 
reasons
+       protected static $damagingPrefMap = [
+               'hard' => 'maybebad',
+               'soft' => 'likelybad',
+               'softest' => 'verylikelybad',
+       ];
 
        /**
         * @param DatabaseUpdater $updater
@@ -637,13 +643,8 @@
        public static function getThreshold( $type, User $user ) {
                if ( $type === 'damaging' ) {
                        $pref = $user->getOption( 'oresDamagingPref' );
-                       $compatMap = [
-                               'hard' => 'maybebad',
-                               'soft' => 'likelybad',
-                               'softest' => 'verylikelybad',
-                       ];
-                       if ( isset( $compatMap[ $pref ] ) ) {
-                               $pref = $compatMap[ $pref ];
+                       if ( isset( self::$damagingPrefMap[ $pref ] ) ) {
+                               $pref = self::$damagingPrefMap[ $pref ];
                        }
                        $thresholds = self::getDamagingThresholds();
                        if ( isset( $thresholds[ $pref ] ) ) {
@@ -670,10 +671,10 @@
 
                $options = [];
                $damagingThresholds = self::getDamagingThresholds();
-               foreach ( [ 'maybebad', 'likelybad', 'verylikelybad' ] as 
$level ) {
+               foreach ( self::$damagingPrefMap as $prefName => $level ) {
                        if ( isset( $damagingThresholds[ $level ] ) ) {
                                $text = \wfMessage( 'ores-damaging-' . $level 
)->text();
-                               $options[ $text ] = $level;
+                               $options[ $text ] = $prefName;
                        }
                }
                $oresSection = $wgOresExtensionStatus === 'beta' ? 'rc/ores' : 
'watchlist/ores';

-- 
To view, visit https://gerrit.wikimedia.org/r/350316
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I228a636abea77548af16a830a8882b3327edc175
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Catrope <r...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to