MediaWikiServices: Don't assume, that old and new instances contains the same services
authorFlorian Schmidt <florian.schmidt.stargatewissen@gmail.com>
Sun, 28 Aug 2016 16:33:40 +0000 (18:33 +0200)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 30 Aug 2016 14:17:04 +0000 (14:17 +0000)
commitacfb8efed82f2514625324cb508be8abaa567f0c
tree1bc148c13a58042ad3706faeb46f7c933748e579
parentb59365e6754cdcd8c718579cd4dc186961f02737
MediaWikiServices: Don't assume, that old and new instances contains the same services

As the services, that are registered in MediaWikiServices can be changed by
extensions using the MediaWikiServices hook, it's not save to assume, that
the first created instance of MediaWikiServices (which could be created before
any extension is loaded, e.g. in ExtensionRegistry) contains the same services
as a later created one (in the reset process of resetGlobalInstance). Doing this
could result in a NoSuchServiceException, if an extension registers new services,
which aren't registered before the extension is loaded (as, in the reset process,
MediaWikiServices tries to minimize the service instantiation cost by preserving
services, that can be preserved).

This patch adds a check, if a service is registered in the MediaWikiServices object
that should be reset, before the salvage-logic tries to fetch the services. If the
service object does not exist, it simply skips it, as it will simply instantiated
later.

Follow up: Ie2ca3ff99aa74fffa9eb6c8faccab857dc0874f7
Follow up: I2a26b6af07a48ad15414a8428daa9cfcfe02e933

Bug: T143974
Change-Id: Ifc587d6138ab565c2f38eb0805acf0dd0473d433
includes/MediaWikiServices.php