HomePhabricator

resourceloader: Audit use of JSON encoding and use json_encode directly

Authored by Krinkle on Aug 16 2018, 7:48 PM.

Description

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