Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
LoadBalancerDisabled | |
0.00% |
0 / 19 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
2 | |||
reallyOpenConnection | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getConnection | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getConnectionInternal | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getConnectionRef | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getMaintenanceConnectionRef | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
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. |
7 | * |
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. |
12 | * |
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 |
17 | * |
18 | * @file |
19 | */ |
20 | namespace Wikimedia\Rdbms; |
21 | |
22 | use RuntimeException; |
23 | |
24 | /** |
25 | * Placeholder LoadBalancer that throws an error upon attempts to access connections |
26 | * |
27 | * This is useful when running code with no config file present, e.g. during installation. |
28 | * |
29 | * @since 1.40 |
30 | * @ingroup Database |
31 | */ |
32 | class LoadBalancerDisabled extends LoadBalancer { |
33 | |
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 | ] ); |
49 | } |
50 | |
51 | /** |
52 | * @param int $i |
53 | * @param DatabaseDomain $domain |
54 | * @param array $lbInfo |
55 | * |
56 | * @return never |
57 | */ |
58 | protected function reallyOpenConnection( $i, DatabaseDomain $domain, array $lbInfo ) { |
59 | throw new RuntimeException( 'Database backend disabled' ); |
60 | } |
61 | |
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 |
67 | * |
68 | * @return never |
69 | */ |
70 | public function getConnection( $i, $groups = [], $domain = false, $flags = 0 ) { |
71 | throw new RuntimeException( 'Database backend disabled' ); |
72 | } |
73 | |
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 |
81 | */ |
82 | public function getConnectionInternal( $i, $groups = [], $domain = false, $flags = 0 ): IDatabase { |
83 | throw new RuntimeException( 'Database backend disabled' ); |
84 | } |
85 | |
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 |
91 | * |
92 | * @return never |
93 | */ |
94 | public function getConnectionRef( $i, $groups = [], $domain = false, $flags = 0 ): DBConnRef { |
95 | throw new RuntimeException( 'Database backend disabled' ); |
96 | } |
97 | |
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 |
103 | * |
104 | * @return never |
105 | */ |
106 | public function getMaintenanceConnectionRef( $i, $groups = [], $domain = false, $flags = 0 ): DBConnRef { |
107 | throw new RuntimeException( 'Database backend disabled' ); |
108 | } |
109 | |
110 | } |