Physikerwelt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/131439

Change subject: Catch misconfiguration of math default option
......................................................................

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
---
M Math.hooks.php
1 file changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/39/131439/1

diff --git a/Math.hooks.php b/Math.hooks.php
index cf20545..e927d71 100644
--- a/Math.hooks.php
+++ b/Math.hooks.php
@@ -141,7 +141,7 @@
         * @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 @@
                                '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 ) ){
+            wfDebug( '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;
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e3c468c0dc92378f7dc7b7d81fb4693e70f6b6f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <w...@physikerwelt.de>

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

Reply via email to