mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-12 09:26:05 +00:00
79e66c4268
They are already cached in db and lb object Change-Id: I3e4db98a3eecdf184db64274b3914eec076af905
32 lines
741 B
PHP
32 lines
741 B
PHP
<?php
|
|
|
|
/**
|
|
* Database factory class, this will determine whether to use the main database
|
|
* or an external database defined in configuration file
|
|
*/
|
|
class MWEchoDbFactory {
|
|
|
|
/**
|
|
* Wrapper function for wfGetDB
|
|
*
|
|
* @param $db int Index of the connection to get
|
|
* @param $groups mixed Query groups.
|
|
* @param $wiki string The wiki ID, or false for the current wiki
|
|
* @return DatabaseBase
|
|
*/
|
|
public static function getDB( $db, $groups = array(), $wiki = false ) {
|
|
global $wgEchoCluster;
|
|
|
|
// Use the external db defined for Echo
|
|
if ( $wgEchoCluster ) {
|
|
$lb = wfGetLBFactory()->getExternalLB( $wgEchoCluster, $wiki );
|
|
} else {
|
|
$lb = wfGetLB( $wiki );
|
|
}
|
|
|
|
return $lb->getConnection( $db, $groups, $wiki );
|
|
|
|
}
|
|
|
|
}
|