Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ReplicaKillSwitch.php

function 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\Database

Code

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);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal