function ReplicaKillSwitch::trigger
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Database/ReplicaKillSwitch.php \Drupal\Core\Database\ReplicaKillSwitch::trigger()
- 10 core/lib/Drupal/Core/Database/ReplicaKillSwitch.php \Drupal\Core\Database\ReplicaKillSwitch::trigger()
- 11.x core/lib/Drupal/Core/Database/ReplicaKillSwitch.php \Drupal\Core\Database\ReplicaKillSwitch::trigger()
Denies access to replica database on the current request.
See also
https://www.drupal.org/node/2286193
File
-
core/
lib/ Drupal/ Core/ Database/ ReplicaKillSwitch.php, line 59
Class
- ReplicaKillSwitch
- Provides replica server kill switch to ignore it.
Namespace
Drupal\Core\DatabaseCode
public function trigger() {
$connection_info = Database::getConnectionInfo();
// Only set ignore_replica_server if there are replica servers being used,
// which is assumed if there are more than one.
if (count($connection_info) > 1) {
// Five minutes is long enough to allow the replica to break and resume
// interrupted replication without causing problems on the Drupal site
// from the old data.
$duration = $this->settings
->get('maximum_replication_lag', 300);
// Set session variable with amount of time to delay before using replica.
$this->session
->set('ignore_replica_server', $this->time
->getRequestTime() + $duration);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.