resourceloader: Replace ResourceLoaderDebug config use with context
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 8 Mar 2019 20:33:04 +0000 (20:33 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 8 Mar 2019 20:33:16 +0000 (20:33 +0000)
commit9a4a754231482f3faf0061be1a177860654bcae7
tree9b79e1c5680e8692f2abf164d750d895f2ad69ea
parentb3b2a72e718cd8c18af9dbb7b1ab80e90dbd79cf
resourceloader: Replace ResourceLoaderDebug config use with context

Reduce our reliance on static state and configuration, and
propagate more state in explicit ways, through context, and
request parameters.

OutputPage creates ResourceLoaderContext and ResourceLoaderClientHtml
based on the configuration (via ResourceLoader::inDebugMode).

Everything within those classes should not need to check it
again.

* ResourceLoaderClientHtml:
  Already doesn't check MW config, but it's test was still
  mocking it. Removed now, and confirmed that it passes both
  with true and false. The individual test cases set
  debug=true/false as needed already.

  It's sets were previously relying on the accidental behaviour
  that within a unit test, we don't serialise over HTTP, which
  meant that a pure PHP boolean would survive. With the new
  raw `=== 'true'` check, this no longer works. Set it as a
  string explicitly instead, which is the only thing we support
  outside unit tests as well.

* ResourceLoaderContext:
  Remove fallback to MW config when 'debug' is unset.
  This is never unset in practice given that all load.php
  urls have it set by OutputPage based on ResourceLoader::inDebugMode.

  This change means that manually constructed ad-hoc load.php
  urls that are missing 'debug=' parameter, will now always be
  read as debug=false. This was the default already, but could
  previously be changed through wgResourceLoaderDebug.

When changing wgResourceLoaderDebug, everything will still have
debug=true as before. The only change is when constructing load.php
urls manually and explicitly not set it.

Bug: T32956
Change-Id: Ie3424be46e2b8311968f3068ca08ba6a1139224a
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderContext.php
tests/phpunit/ResourceLoaderTestCase.php
tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderTest.php