JSON i18n shim: Only register LocalisationCacheRecache handler once
authorKevin Israel <pleasestand@live.com>
Mon, 14 Apr 2014 11:24:32 +0000 (07:24 -0400)
committerKevin Israel <pleasestand@live.com>
Thu, 17 Apr 2014 12:59:07 +0000 (08:59 -0400)
commite0736bd1cdb3c2971baf344006f474580b8e326c
treea263369b737c66ce0b07ee53dda0170d00cc26fd
parenta580d5d60efaef9f8051a6fdbb8a869b289dce6b
JSON i18n shim: Only register LocalisationCacheRecache handler once

Because LocalisationCache::recache() includes PHP shims each time it is
called (e.g. for a different language), in such cases as automated testing,
the shims could end up registering handlers many times instead of only
once, leading to a rather significant, progressively worse slowdown.

Checking whether the shim has already been loaded, and if so, not
registering the handler again, avoids this performance problem.

I also made the shim compatible with PHP 5.2 (minimum PHP version for
MW 1.17 - 1.19) by avoiding closures and __DIR__, and I added a
--shim-only option to generateJsonI18n.php to allow regenerating
existing shims.

Bug: 63928
Change-Id: I3bb39e7d2bb094873061b3b2adf7066bf26c1b71
maintenance/generateJsonI18n.php