Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / libs / rdbms / loadbalancer / LoadBalancerDisabled.php
blobc194d2d8026e7fc14054795af2087bcc64557f5c
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
20 namespace Wikimedia\Rdbms;
22 use RuntimeException;
24 /**
25 * Placeholder LoadBalancer that throws an error upon attempts to access connections
27 * This is useful when running code with no config file present, e.g. during installation.
29 * @since 1.40
30 * @ingroup Database
32 class LoadBalancerDisabled extends LoadBalancer {
34 public function __construct( $params = [] ) {
35 parent::__construct( [
36 'servers' => [ [
37 'type' => 'disabled',
38 'host' => '(disabled)',
39 'dbname' => null,
40 'load' => 1,
41 ] ],
42 'trxProfiler' => $params['trxProfiler'] ?? null,
43 'srvCache' => $params['srvCache'] ?? null,
44 'wanCache' => $params['wanCache'] ?? null,
45 'localDomain' => $params['localDomain'] ?? '(disabled)',
46 'readOnlyReason' => $params['readOnlyReason'] ?? false,
47 'clusterName' => $params['clusterName'] ?? null,
48 ] );
51 /**
52 * @param int $i
53 * @param DatabaseDomain $domain
54 * @param array $lbInfo
56 * @return never
58 protected function reallyOpenConnection( $i, DatabaseDomain $domain, array $lbInfo ) {
59 throw new RuntimeException( 'Database backend disabled' );
62 /**
63 * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
64 * @param string[]|string $groups Query group(s) in preference order; [] for the default group
65 * @param string|false $domain DB domain ID or false for the local domain
66 * @param int $flags Bitfield of CONN_* class constants
68 * @return never
70 public function getConnection( $i, $groups = [], $domain = false, $flags = 0 ) {
71 throw new RuntimeException( 'Database backend disabled' );
74 /**
75 * @internal Only to be used by DBConnRef
76 * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
77 * @param string[]|string $groups Query group(s) in preference order; [] for the default group
78 * @param string|false $domain DB domain ID or false for the local domain
79 * @param int $flags Bitfield of CONN_* class constants (e.g. CONN_TRX_AUTOCOMMIT)
80 * @return never
82 public function getConnectionInternal( $i, $groups = [], $domain = false, $flags = 0 ): IDatabase {
83 throw new RuntimeException( 'Database backend disabled' );
86 /**
87 * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
88 * @param string[]|string $groups Query group(s) in preference order; [] for the default group
89 * @param string|false $domain DB domain ID or false for the local domain
90 * @param int $flags Bitfield of CONN_* class constants
92 * @return never
94 public function getConnectionRef( $i, $groups = [], $domain = false, $flags = 0 ): DBConnRef {
95 throw new RuntimeException( 'Database backend disabled' );
98 /**
99 * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
100 * @param string[]|string $groups Query group(s) in preference order; [] for the default group
101 * @param string|false $domain DB domain ID or false for the local domain
102 * @param int $flags Bitfield of CONN_* class constants
104 * @return never
106 public function getMaintenanceConnectionRef( $i, $groups = [], $domain = false, $flags = 0 ): DBConnRef {
107 throw new RuntimeException( 'Database backend disabled' );