aboutsummaryrefslogtreecommitdiffstats
path: root/includes/config/ConfigFactory.php
Commit message (Collapse)AuthorAgeFilesLines
* Drop hard-deprecated ConfigFactory::getDefaultInstance()Taavi Väänänen2024-04-211-12/+0
| | | | | Bug: T325966 Change-Id: I3c3c11946c5aa975358cd3a1cc8289b9be89e694
* Standardise all our class alias deprecation comments for ease of greppingJames D. Forrester2024-03-191-4/+1
| | | | Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
* Namespace Config-related classes under \MediaWiki\ConfigJames D. Forrester2023-09-211-0/+10
| | | | | Bug: T166010 Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
* ConfigFactory: Hard-deprecate getDefaultInstance()James D. Forrester2023-08-191-0/+2
| | | | Change-Id: I42d30ddcb9ce9a51f9d7a56bc19f0094dca85d5b
* Refactor global variables to use MediaWikiServices insteadTChin2022-01-101-1/+3
| | | | | | | | | | | | Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI. Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228 * This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it. A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
* Better docs to make phan happyDaimona Eaytoy2019-09-071-1/+2
| | | | Change-Id: I8a9a6330cf1f889cbb77dfc28c93774204767323
* Fix usage of MediaWikiServices in comments and documentationFomafix2019-03-031-1/+1
| | | | | | | | | | MediaWikiServices::getFoo() is wrong. Right is: MediaWikiServices::getInstance()->getFoo() Change-Id: Ib6d844ddfe5bd6ccd72b887a63d9ad476c8d196f
* Fully extract services framework as a libraryLucas Werkmeister2019-01-161-1/+1
| | | | | | | | | | | This code doesn’t use any MediaWiki-specific code, so rename MediaWiki\Services to Wikimedia\Services and move it below libs/. (Of course, this does not apply to the MediaWikiServices subclass.) Class aliases are added to retain backwards compatibity for now. Bug: T211608 Change-Id: Ic14ea28ef21c359695b309d4293dbaaf5deedc09
* ConfigFactory: Improve error message for invalid callbackUmherirrender2018-01-201-1/+6
| | | | | | | | | | | | | | Getting the following error for an invalid callback in extension registration is not helpful: Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Invalid callback provided' in /includes/config/ConfigFactory.php:108 Changed message to Invalid callback '$1' provided Added a test case for the instanceof part of the if Change-Id: I425e2607b651c666336289c2c0d93730bb6312ed
* Fix typo in word "callback"Umherirrender2017-12-311-1/+1
| | | | Change-Id: If47b9d80df4189317ec41998b35546a6118288c2
* Allow resources to be salvaged across service resets.daniel2016-05-191-16/+47
| | | | | | | | | NOTE: This also changes the semantics of MediaWikiServices::resetGlobalInstance to only reset services instances, not service wiring. The wiring will be copied from the old global MediaWikiServices instance to the new one. Bug: T132707 Change-Id: Ie2ca3ff99aa74fffa9eb6c8faccab857dc0874f7
* Allow reset of global services (redux).daniel2016-05-041-5/+33
| | | | | | | | | | | | | | | | | | | | | | | (This is part of I6ec374ac9 wich was a re-submit of Ie98bf5af5 which got reverted by Ide7ab563) This change provides a mechanism to reset global service instances in an orderly manner. There are three use cases for this: * the installation process * integration tests (which most of the existing phpunit tests are) In contrast to I6ec374ac9, this change does not cause singeltons of legacy services to be reset. It is assumed that legacy services use global state to access services and configuration, so any change in confuguration would affect them immediately. NOTE: the original I6ec374ac9 would cause session information to get lost if the user session was creatsed before initialization was complete. This was apparently triggered by the MobileFrontend extension under some circumstances. Check with Addshore and Catrope. Change-Id: Ie06782ffb96e675c0aa55dc26fb8f22037e8517d
* Revert "Allow reset of global services."Catrope2016-04-111-33/+5
| | | | | | | | Completely breaks login. This reverts commit 8e7a0a0912bb98a4a12375b354e23f03262bf213. Change-Id: Ide7ab5632e987e81374c21173df6ab3998649df7
* Allow reset of global services.daniel2016-04-111-5/+33
| | | | | | | | | | | | This change provides a mechanism to reset global service instances in an orderly manner. There are three use cases for this: * the installation process * forking processes * integration tests (which must of the existing phpunit tests are) Depends-On: I5d638ad415fc3840186a0beaa09ac02ea688539b Change-Id: Ie98bf5af59208f186dba59a9e971c72ea0b63e69
* Introduce top level service locator.daniel2016-04-021-27/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | The service locator, MediaWikiServices, is intended to facilitate "manual" dependency injection in static entry points. See also the Dependency Injection RFC T384 and Service Locator RFC T124792 for details. The following key points were implemented according the discussion surrounding these RFCs: * a configurable DI container that allows extensions to add and replace services. * no auto-wiring, since it's prone to add confusion in large and complex applications. * no 3rd party framework, since they typically do too much. The following services in MediaWiki core are made accessible via the service locator mechanism to showcase the bootstrapping mechanism: * ConfigFactory and MainConfig * SiteLookup and SiteStore However, the implementation of these services was not yet converted to using proper DI throughout the code. Bug: T124792 Change-Id: I3c25c0ac17300d3dd13e1cf5100558a605eee15f
* Convert all array() syntax to []Kunal Mehta2016-02-171-2/+2
| | | | | | | | | | 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
* Added getDefaultInstance() return type docAaron Schulz2015-05-131-0/+3
| | | | Change-Id: I9662738efb660f85a5c8e63c37f385d28539de75
* Mark ConfigFactory::destroyDefaultInstance() with @codeCoverageIgnoreKunal Mehta2014-08-221-0/+1
| | | | Change-Id: Icd4a5724aefab58dad1af07874ef7ee415922ead
* Add tests for ConfigFactory::getDefaultInstanceKunal Mehta2014-08-031-5/+22
| | | | Change-Id: I6d356458dfe0a66f9af12ab58a6b1dcf47b6325a
* Cleanup some docs (includes/[a-d])umherirrender2014-07-241-5/+5
| | | | | | | | | | - Swap "$variable type" to "type $variable" - Added missing types - Fixed spacing inside docs - Makes beginning of @param/@return/@var/@throws in capital - Changed some types to match the more common spelling Change-Id: I7b65fe04db431342cc58b469dc48f41a50c4e891
* Make abstract Config class truly implementation-agnosticKunal Mehta2014-05-261-0/+94
Follow up to I13baec0b6 ("Config: Add Config and GlobalConfig classes"): Config: * Rather than returning Status objects, Config::set will now throw an exception if an error is encountered * Config::factory was moved into it's own ConfigFactory class. * Since there are no more functions in it, Config was turned into an interface. GlobalConfig: * Remove $prefix args from Config::set and ::get. The idea of having an abstract Config class is to abstract some notion of configuration data from the particular way in which it is currently implemented (global variables). So the abstract base class has no business dealing with variable name prefixes. ** Instead GlobalVarConfig's implementations of get and set call getWithPrefix and setWithPrefix internally, which are now protected * Rename GlobalConfig to GlobalVarConfig, which makes it clearer that it isn't referring to the scope of the configuration value, but to the scope of the variable name which provides it. ConfigFactory: * ConfigFactory is where Config objects are registered, and later constructed. * Config objects are registered with a given name, and a callback factory function. This allows for implementations to construct the object with the parameters they want, and avoids the overhead of needing an entire class. ** The name 'main' is the default object returned by RequestContext::getConfig(), and is intended to be used by core. * This is a singleton class, the main instance can be obtained with: ConfigFactory::getDefaultInstance() In addition to the above: * $wgConfigClass was removed, and $wgConfigRegistry was introduced, which stores a name => callback. The name is to be what the Config instance is registered with, and the callback should return an implementation of Config. * Tests were written for the new ConfigFactory, and GlobalVarConfig's tests were improved. Co-Authored-By: Ori Livneh <ori@wikimedia.org> Co-Authored-By: Chad Horohoe <chadh@wikimedia.org> Co-Authored-By: Mattflaschen <mflaschen@wikimedia.org> Co-Authored-By: Parent5446 <tylerromeo@gmail.com> Co-Authored-By: Reedy <reedy@wikimedia.org> Co-Authored-By: Daniel Kinzler <daniel.kinzler@wikimedia.de> Change-Id: I5a5857fcfa07598ba4ce9ae5bbb4ce54a567d31e