From bb9edf4f7a88b7bc398dfa46ed9e628fb87d5d8c Mon Sep 17 00:00:00 2001 From: physikerwelt Date: Mon, 5 May 2014 09:38:20 +0000 Subject: [PATCH] Catch misconfiguration of math default option If the LocalSettings.php has invalid settings for $wgDefaultUserOptions['math'] and $wgValidMathModes the user prefrences pages displays an error. This commit catches this error and selects the first rendering option availible. Bug: 64844 Change-Id: I1e3c468c0dc92378f7dc7b7d81fb4693e70f6b6f --- Math.hooks.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Math.hooks.php b/Math.hooks.php index cf20545b7..87d669e2e 100644 --- a/Math.hooks.php +++ b/Math.hooks.php @@ -141,7 +141,7 @@ class MathHooks { * @return Boolean: true */ static function onGetPreferences( $user, &$defaultPreferences ) { - global $wgUseMathJax; + global $wgUseMathJax, $wgMathValidModes, $wgDefaultUserOptions; $defaultPreferences['math'] = array( 'type' => 'radio', 'options' => array_flip( self::getMathNames() ), @@ -155,6 +155,13 @@ class MathHooks { 'section' => 'rendering/math', ); } + // If the default option is not in the valid options the + // user interface throws an exception (BUG 64844) + if ( ! in_array( $wgDefaultUserOptions['math'] , $wgMathValidModes ) ){ + wfDebugLog( 'Math', "Warning: Misconfiguration \$wgDefaultUserOptions['math'] is not in \$wgMathValidModes. Please check your LocalSetting.php file."); + // Display the checkbox in the first option. + $wgDefaultUserOptions['math'] = $wgMathValidModes[0]; + } return true; }