ResourceLoader: Fail less hard when JSON serialization of config fails
authorRoan Kattouw <roan.kattouw@gmail.com>
Wed, 7 Nov 2018 23:04:50 +0000 (15:04 -0800)
committerRoan Kattouw <roan.kattouw@gmail.com>
Wed, 7 Nov 2018 23:04:50 +0000 (15:04 -0800)
Instead of throwing an exception on the PHP side, log an error on the JS
side.

Change-Id: I673f59d936e48072e78f6b061ac06f37274ded77

includes/resourceloader/ResourceLoader.php

index 2fc81e3..9570e03 100644 (file)
@@ -1529,10 +1529,12 @@ MESSAGE;
                        self::inDebugMode()
                );
                if ( $js === false ) {
-                       throw new Exception(
+                       $e = new Exception(
                                'JSON serialization of config data failed. ' .
                                'This usually means the config data is not valid UTF-8.'
                        );
+                       MWExceptionHandler::logException( $e );
+                       $js = Xml::encodeJsCall( 'mw.log.error', [ $e->__toString() ] );
                }
                return $js;
        }