26use InvalidArgumentException;
167 parent::__construct(
$conf );
170 $required = [
'sectionsByDB',
'sectionLoads',
'serverTemplate' ];
171 $optional = [
'groupLoadsBySection',
'groupLoadsByDB',
'hostsByName',
172 'externalLoads',
'externalTemplateOverrides',
'templateOverridesByServer',
173 'templateOverridesByCluster',
'templateOverridesBySection',
'masterTemplateOverrides',
174 'readOnlyBySection',
'loadMonitorClass' ];
176 foreach ( $required as $key ) {
177 if ( !isset(
$conf[$key] ) ) {
178 throw new InvalidArgumentException( __CLASS__ .
": $key is required." );
180 $this->$key =
$conf[$key];
183 foreach ( $optional as $key ) {
184 if ( isset(
$conf[$key] ) ) {
185 $this->$key =
$conf[$key];
195 if ( $this->lastDomain === $domain ) {
199 if ( isset( $this->sectionsByDB[$dbName] ) ) {
200 $section = $this->sectionsByDB[$dbName];
205 $this->lastDomain = $domain;
217 if ( isset( $this->groupLoadsByDB[$dbName] ) ) {
218 $groupLoads = $this->groupLoadsByDB[$dbName];
223 if ( isset( $this->groupLoadsBySection[
$section] ) ) {
224 $groupLoads = array_merge_recursive(
225 $groupLoads, $this->groupLoadsBySection[
$section] );
235 if ( isset( $this->templateOverridesBySection[
$section] ) ) {
253 if ( !isset( $this->mainLBs[
$section] ) ) {
261 if ( !isset( $this->externalLoads[$cluster] ) ) {
262 throw new InvalidArgumentException( __METHOD__ .
": Unknown cluster \"$cluster\"" );
265 if ( $this->externalTemplateOverrides ) {
268 if ( isset( $this->templateOverridesByCluster[$cluster] ) ) {
274 $this->externalLoads[$cluster],
276 $this->readOnlyReason
281 if ( !isset( $this->extLBs[$cluster] ) ) {
285 return $this->extLBs[$cluster];
290 foreach ( $this->sectionsByDB as $db =>
$section ) {
301 foreach ( $this->externalLoads as $cluster => $unused ) {
322 'loadMonitor' => [
'class' => $this->loadMonitorClass ],
343 foreach ( $groupLoadsByServer as $server => $stuff ) {
344 if ( !isset( $loads[$server] ) ) {
348 foreach ( $loads as $serverName => $load ) {
351 $serverInfo[
'master'] =
true;
352 if ( $this->masterTemplateOverrides ) {
353 $serverInfo = $this->masterTemplateOverrides + $serverInfo;
357 $serverInfo[
'replica'] =
true;
359 if ( isset( $this->templateOverridesByServer[$serverName] ) ) {
360 $serverInfo = $this->templateOverridesByServer[$serverName] + $serverInfo;
362 if ( isset( $groupLoadsByServer[$serverName] ) ) {
363 $serverInfo[
'groupLoads'] = $groupLoadsByServer[$serverName];
365 if ( isset( $this->hostsByName[$serverName] ) ) {
366 $serverInfo[
'host'] = $this->hostsByName[$serverName];
368 $serverInfo[
'host'] = $serverName;
370 $serverInfo[
'hostName'] = $serverName;
371 $serverInfo[
'load'] = $load;
372 $serverInfo += [
'flags' => IDatabase::DBO_DEFAULT ];
374 $servers[] = $serverInfo;
387 foreach ( $groupLoads as $group => $loads ) {
388 foreach ( $loads as $server => $load ) {
389 $reindexed[$server][$group] = $load;
401 $domain = ( $domain ===
false )
405 return [ $domain->getDatabase(), $domain->getTablePrefix() ];
416 foreach ( $this->mainLBs as $lb ) {
417 call_user_func_array( $callback, array_merge( [ $lb ],
$params ) );
419 foreach ( $this->extLBs as $lb ) {
420 call_user_func_array( $callback, array_merge( [ $lb ],
$params ) );
static newFromId( $domain)
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
processing should stop and the error should be shown to the user * false