aboutsummaryrefslogtreecommitdiffstats
path: root/docs/Injection.md
diff options
context:
space:
mode:
authorBartosz Dziewoński <dziewonski@fastmail.fm>2024-01-22 23:05:26 +0100
committerBartosz Dziewoński <dziewonski@fastmail.fm>2024-01-23 14:04:31 +0000
commitd726cdfd3de1ba2f0b0b28237ef153460566617e (patch)
treef1464e3aea21fca3fd3a7e39aa50a04ff93a2656 /docs/Injection.md
parente4c7272976efb123919fcc96534446bfa1edb18c (diff)
downloadmediawikicore-d726cdfd3de1ba2f0b0b28237ef153460566617e.tar.gz
mediawikicore-d726cdfd3de1ba2f0b0b28237ef153460566617e.zip
Injection.md: Improve advice about replacing wfGetDB()
Change-Id: Ic9b3208f736ef90639c10d0efabaa7f4e8d970db
Diffstat (limited to 'docs/Injection.md')
-rw-r--r--docs/Injection.md11
1 files changed, 6 insertions, 5 deletions
diff --git a/docs/Injection.md b/docs/Injection.md
index 850a96ce6b7a..b92e54c4d8a9 100644
--- a/docs/Injection.md
+++ b/docs/Injection.md
@@ -169,10 +169,11 @@ Assume `Foo` is a class that uses the `$wgScriptPath` global and calls
`wfGetDB()` to get a database connection, in non-static methods.
* Add `$scriptPath` as a constructor parameter and use `$this->scriptPath`
instead of `$wgScriptPath`.
-* Add LoadBalancer `$dbLoadBalancer` as a constructor parameter. Use
- `$this->dbLoadBalancer->getConnection()` instead of `wfGetDB()`.
+* Add IConnectionProvider `$dbProvider` as a constructor parameter. Use
+ `$this->dbProvider->getReplicaDatabase()` instead of `wfGetDB( DB_REPLICA )`,
+ `$this->dbProvider->->getPrimaryDatabase()` instead of `wfGetDB( DB_PRIMARY )`.
* Any code that calls `Foo`'s constructor would now need to provide the
- `$scriptPath` and `$dbLoadBalancer`. To avoid this, avoid direct instantiation
+ `$scriptPath` and `$dbProvider`. To avoid this, avoid direct instantiation
of services all together - see below.
### Migrate services with multiple configuration variables
@@ -347,9 +348,9 @@ For this purpose, `Thingy` uses wfGetDB().
record's data with a single `ThingyRecord` object.
* In the old Thingy class, replace all calls to static methods or functions,
such as wfGetDB(), with calls to the appropriate services, such as
- `LoadBalancer::getConnection()`.
+ `IConnectionProvider::getReplicaDatabase()`.
* In Thingy's constructor, pull in any services needed, such as the
- LoadBalancer, by using `MediaWikiServices::getInstance()`. These services
+ IConnectionProvider, by using `MediaWikiServices::getInstance()`. These services
cannot be injected without changing the constructor signature, which
is often impractical for "smart records" that get instantiated directly
in many places in the code base.