Catrope has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/350504 )
Change subject: Don't break the entire preferences page if the ORES API is down
......................................................................
Don't break the entire preferences page if the ORES API is down
If the ORES API is down or otherwise not giving us a response we expect,
and all damaging thresholds are defined in terms of model stats,
getDamagingThresholds() will fail to resolve all of them and return
an empty array. This caused the set of allowed values for the oresDamagingPref
preference to be set to an empty array, which then causes the
preferences page to die with an exception because the default
value is not in the (empty) array of allowed values.
To fix this, don't make the allowed values for this preference
depend on the API result, but only on the $wgOresFiltersThresholds
config.
Change-Id: I94f551bb25aa20336a5ae93ed45d0b090bacf44f
---
M includes/Hooks.php
1 file changed, 7 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES
refs/changes/04/350504/1
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 859f7f6..57cdb11 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -662,16 +662,20 @@
* @param string[] $preferences
*/
public static function onGetPreferences( User $user, array
&$preferences ) {
- global $wgOresExtensionStatus, $wgHiddenPrefs;
+ global $wgOresFiltersThresholds, $wgOresExtensionStatus,
$wgHiddenPrefs;
if ( !self::oresEnabled( $user ) || !self::isModelEnabled(
'damaging' ) ) {
return;
}
$options = [];
- $damagingThresholds = self::getDamagingThresholds();
foreach ( [ 'maybebad', 'likelybad', 'verylikelybad' ] as
$level ) {
- if ( isset( $damagingThresholds[ $level ] ) ) {
+ // In other places, we look at the keys of
getDamagingThresholds() to determine which
+ // damaging levels exist, but it can drop levels from
its output if the ORES API
+ // has issues. We don't want preference definitions to
be potentially unstable.
+ // So instead, we use $wgOresFiltersThresholds directly
so the preference definition
+ // only depends on the configuration.
+ if ( $wgOresFiltersThresholds[ 'damaging' ][ $level ]
!== false ) {
$text = \wfMessage( 'ores-damaging-' . $level
)->text();
$options[ $text ] = $level;
}
--
To view, visit https://gerrit.wikimedia.org/r/350504
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I94f551bb25aa20336a5ae93ed45d0b090bacf44f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits