resourceloader: Avoid endless module_deps write for the same value
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 22 Feb 2017 21:54:40 +0000 (13:54 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 22 Feb 2017 22:32:45 +0000 (22:32 +0000)
commite2c4c40c96b678742ebad913727893c8340ca4c5
tree42fccb6b3252d32e2c51ae7101b8a42df52c49bd
parent4cb9c1a24bde6e29c5e8f05c7cd1de54ffdd342a
resourceloader: Avoid endless module_deps write for the same value

Follows-up 047b60b96d (ref T111481).

The if-condition compared the expanded paths, not the relative paths.
This meant there were two conditions under which the code will perform
a useless write that inserts *literally* the exact same JSON value.

1. The base directory ($IP) changes after a branch upgrade.
2. Paths contain '../', '//' or other unnormalized paths.

The latter caused various Echo and ULS methods to keep writing the
same value because one of their images is referenced in CSS using
'../'. When inserted in the database as relative path and then
expanded again at run-time and compared to the input value, they
don't match ("$IP/foo/../bar.png" != "$IP/bar.png") and cause a write.

Bug: T158813
Change-Id: I223c232d3a8c4337d09ecf7ec6e5cd7cf7effbff
includes/resourceloader/ResourceLoaderModule.php