You are here

protected function InPlaceUpdate::rollback in Automatic Updates 8

Rollback after a failed update.

Parameters

string $project_root: The project root directory.

1 call to InPlaceUpdate::rollback()
InPlaceUpdate::update in src/Services/InPlaceUpdate.php
Update a project to the next release.

File

src/Services/InPlaceUpdate.php, line 455

Class

InPlaceUpdate
Class to apply in-place updates.

Namespace

Drupal\automatic_updates\Services

Code

protected function rollback($project_root) {
  if (!$this->backup) {
    return;
  }
  foreach ($this
    ->getFilesList($this
    ->getTempDirectory()) as $file) {
    $file_real_path = $this
      ->getFileRealPath($file);
    $file_path = substr($file_real_path, strlen($this
      ->getTempDirectory() . self::ARCHIVE_DIRECTORY));
    $project_real_path = $this
      ->getProjectRealPath($file_path, $project_root);
    try {
      $this->fileSystem
        ->delete($project_real_path);
      $this->logger
        ->info('"@file" was successfully removed during rollback.', [
        '@file' => $project_real_path,
      ]);
    } catch (FileException $exception) {
      $this->logger
        ->error('"@file" failed removal on rollback.', [
        '@file' => $project_real_path,
      ]);
    }
  }
  foreach ($this
    ->getFilesList($this->backup) as $file) {
    $this
      ->doRestore($file, $project_root);
  }
}