You are here

function _backup_migrate_set_timeout in Backup and Migrate 7.3

Increase the execution timeout, and also the database connection timeout.

2 calls to _backup_migrate_set_timeout()
backup_migrate_perform_backup in ./backup_migrate.module
Perform a backup with the given settings.
backup_migrate_perform_restore in ./backup_migrate.module
Restore from a file in the given destination.

File

./backup_migrate.module, line 1988
Backup and restore databases for Drupal.

Code

function _backup_migrate_set_timeout() {

  // If not in 'safe mode', increase the maximum execution time:
  $backup_max_time = variable_get('backup_migrate_backup_max_time', BACKUP_MIGRATE_BACKUP_MAX_TIME);
  if (!ini_get('safe_mode') && ini_get('max_execution_time') < $backup_max_time) {
    drupal_set_time_limit($backup_max_time);
  }

  // Also increase the time mysql keeps the connection open.
  if (Database::getConnection() instanceof DatabaseConnection_mysql) {
    $mysql_wait_timeout = db_query('SELECT @@session.wait_timeout')
      ->fetchField();
    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);
    }
  }
}