1 backup.mysql.inc protected BackupMySql::prepareEnvironment()

Prepare the PHP environment for performing a backup or restore.

Overrides Backup::prepareEnvironment

File

core/includes/backup/backup.mysql.inc, line 494
Contains the BackupMySQL class.

Class

BackupMySql
Creates and restores backups from a MySQL database source.

Code

protected function prepareEnvironment() {
  parent::prepareEnvironment();

  // Increase the MySQL wait timeout if needed to prevent disconnects.
  list(, $db_target) = explode(':', $this->getTarget(), 2);
  $options = array(
    'target' => $db_target,
  );
  $mysql_wait_timeout = db_query('SELECT @@session.wait_timeout', array(), $options)->fetchField();
  $backup_max_time = $this->settings['backup_max_time'];
  if ($mysql_wait_timeout < $backup_max_time) {
    // This does not work with placeholders, so sanitize by casting to int.
    db_query('SET SESSION wait_timeout = ' . (int) $backup_max_time, array(), $options);
  }
}