Commit graph

6 commits

Author SHA1 Message Date
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Timo Tijhof
8c00d37f47 resourceloader: Include 'raw' in ResourceLoaderContext hash
This parameter was introduced last year as a way to extract
bare scripts from modules without any 'mw.loader.state()' suffix.

When ResourceFileCache is used ($wgUseFileCache) this causes
cache pollution as it didn't include getRaw() in the hash.

Change-Id: I7b9f9b6a5756777462395b911abafb62468cbefa
2015-11-17 21:48:03 +00:00
Timo Tijhof
764122c000 resourceloader: Reformat code around member grouping in ResourceLoaderContext
* No effective change. Only code reformatting.
* Logically group related members.
* Break up items one per line in getHash().

Change-Id: I8ccbe9d071a5c39f5c3d36d0d990574fb0ed8d72
2015-11-17 21:47:24 +00:00
Timo Tijhof
b632900f4d resourceloader: Omit getDirection() ResourceLoaderContext hash
The direction is derived from the language code, which is included
already. The method was added for convenience to consuming code,
but including it in the cache key seems pointless.

Main rationale here is runtime performance. getDirection() incurs
Language::factory() and Language::getDir() which require loading
of LCStore files.

Change-Id: I397a1c483203ec2c4903046c9494cae1c9480f8c
2015-11-17 21:38:33 +00:00
Timo Tijhof
149d721e75 resourceloader: Fix broken getRequest/getDirection in derived context
getDirection() isn't a simple getter value like the others. It actually
is tightly coupled with getLanguage() and lazy-initialised.

When calling setLanguage(), we shouldn't reset direction back to the
parent class but make sure getDirection() will recompute it based
on the local value.

Added regression test (which fails without this patch).

The parent getDirection() looks for $this->request, but the subclass
doesn't assign that member in the constructor. getRequest() forwards
it accordingly, so make sure getRequest() is also used internally.

Change-Id: Ifec703647368c3bb58748288ed754aaaf3730e19
2015-06-13 06:00:33 +01:00
Timo Tijhof
d20583dd19 resourceloader: Use -1 instead of null in DerivativeResourceLoaderContext
The ResourceLoaderContext class used null to determine absence of
an overridde in the derivative object.

However three of the members in question allow null as legitimate value.
(Namely 'only', 'user', and 'version').

This makes is impossible for a derivative context to remove one
of those values if the parent context has them set.

Use case: I782df43c needs to create a derivative context of
          load.php?only=scripts&modules=startup without 'only'.

Use -1 instead as internal placeholder value.

Also:

* ResourceLoaderContext::getSkin() was documented as returning 'string|null' when in
  fact it always has a default value. Never returns null.

* DerivativeResourceLoaderContext::setOnly() and setVersion() were missing
  type hint for 'null' (as it was incompatible with their getter). Adding 'false'.

* Swap if/else statements to handle the special case first (inheriting).
  Allowing the rest of the function body to handle the local value.
  In preparation for further development.

Change-Id: I058884525237effe8aef35469ed7693bb7cea591
2015-06-13 05:55:20 +01:00