Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
LoadBalancerDisabled
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 5
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
2
 reallyOpenConnection
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getConnection
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getConnectionInternal
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMaintenanceConnectionRef
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 */
6namespace Wikimedia\Rdbms;
7
8use RuntimeException;
9
10/**
11 * Placeholder LoadBalancer that throws an error upon attempts to access connections
12 *
13 * This is useful when running code with no config file present, e.g. during installation.
14 *
15 * @since 1.40
16 * @ingroup Database
17 */
18class LoadBalancerDisabled extends LoadBalancer {
19
20    public function __construct( array $params = [] ) {
21        parent::__construct( [
22            'servers' => [ [
23                'type' => 'disabled',
24                'host' => '(disabled)',
25                'dbname' => null,
26                'load' => 1,
27            ] ],
28            'trxProfiler' => $params['trxProfiler'] ?? null,
29            'srvCache' => $params['srvCache'] ?? null,
30            'wanCache' => $params['wanCache'] ?? null,
31            'localDomain' => $params['localDomain'] ?? '(disabled)',
32            'readOnlyReason' => $params['readOnlyReason'] ?? false,
33            'clusterName' => $params['clusterName'] ?? null,
34        ] );
35    }
36
37    /**
38     * @param int $i
39     * @param DatabaseDomain $domain
40     * @param array $lbInfo
41     *
42     * @return never
43     */
44    protected function reallyOpenConnection( $i, DatabaseDomain $domain, array $lbInfo ): never {
45        throw new RuntimeException( 'Database backend disabled' );
46    }
47
48    /**
49     * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
50     * @param string[]|string $groups Query group(s) in preference order; [] for the default group
51     * @param string|false $domain DB domain ID or false for the local domain
52     * @param int $flags Bitfield of CONN_* class constants
53     *
54     * @return never
55     */
56    public function getConnection( $i, $groups = [], string|false $domain = false, $flags = 0 ): never {
57        throw new RuntimeException( 'Database backend disabled' );
58    }
59
60    /**
61     * @internal Only to be used by DBConnRef
62     * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
63     * @param string[]|string $groups Query group(s) in preference order; [] for the default group
64     * @param string|false $domain DB domain ID or false for the local domain
65     * @param int $flags Bitfield of CONN_* class constants (e.g. CONN_TRX_AUTOCOMMIT)
66     * @return never
67     */
68    public function getConnectionInternal( $i, $groups = [], $domain = false, $flags = 0 ): never {
69        throw new RuntimeException( 'Database backend disabled' );
70    }
71
72    /**
73     * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
74     * @param string[]|string $groups Query group(s) in preference order; [] for the default group
75     * @param string|false $domain DB domain ID or false for the local domain
76     * @param int $flags Bitfield of CONN_* class constants
77     *
78     * @return never
79     */
80    public function getMaintenanceConnectionRef( $i, $groups = [], $domain = false, $flags = 0 ): never {
81        throw new RuntimeException( 'Database backend disabled' );
82    }
83
84}