resourceloader: Audit use of JSON encoding and use json_encode directly
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 16 Aug 2018 19:48:59 +0000 (20:48 +0100)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 29 Aug 2018 00:46:11 +0000 (00:46 +0000)
commitdc3fc6cf81ecc2c84e6e45f3f4401c4b8976861c
tree47b17089ad06bee7afda9caee39b3a51ad7b4d97
parent8ea2a1e9d16e5bdba1d67d1eaa6659006033d4bf
resourceloader: Audit use of JSON encoding and use json_encode directly

* Remove use of MediaWiki's FormatJson class. Ref T32956.

* FormatJson::decode() was a direct alias of json_decode.

* FormatJson::encode() is a wrapper for json_encode that
  sets `JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP`
  by default, plus a boolean parameter to add JSON_PRETTY_PRINT.

  Instead, use json_encode() directly. By default json_encode() escapes
  slashes and non-ASCII unicode.

* Audit our uses of JSON encoding, document their needs, and set flags
  as needed.

* Remove $mapToJson abstraction from ResourceLoaderStartUpModule.

* Always pretty-print the list of module names in the error message,
  regardless of debug mode.

* Remove hacky indentation-adder from ResourceLoaderStartUpModule.
  This was relying on there not being line breaks in the json output
  outside debug mode, and adding a level of indentation to roughly
  match the code in the JSON is substituted. This didn't match and
  just generally doesn't seem worth it.

Change-Id: I3e09ddeb4d53c8980195c1855303c0ee25bd4c20
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderModule.php
includes/resourceloader/ResourceLoaderStartUpModule.php