jenkins-bot has submitted this change and it was merged. (
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, 10 insertions(+), 3 deletions(-)
Approvals:
Sbisson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 223c022..dd7f7a9 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -663,16 +663,23 @@
* @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 ( self::$damagingPrefMap as $prefName => $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 (
+ isset( $wgOresFiltersThresholds[ 'damaging' ][
$level ] ) &&
+ $wgOresFiltersThresholds[ 'damaging' ][ $level
] !== false
+ ) {
$text = \wfMessage( 'ores-damaging-' . $level
)->text();
$options[ $text ] = $prefName;
}
--
To view, visit https://gerrit.wikimedia.org/r/350504
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I94f551bb25aa20336a5ae93ed45d0b090bacf44f
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits