You are here

protected static function InPlaceUpdate::doRestore in Automatic Updates 7

Do restore.

Parameters

\SplFileInfo $file: File to restore.

string $project_root: The project root directory.

1 call to InPlaceUpdate::doRestore()
InPlaceUpdate::rollback in ./InPlaceUpdate.php
Rollback after a failed update.

File

./InPlaceUpdate.php, line 374

Class

InPlaceUpdate
Class to apply in-place updates.

Code

protected static function doRestore(\SplFileInfo $file, $project_root) {
  $file_real_path = self::getFileRealPath($file);
  $file_path = substr($file_real_path, strlen(self::$backup));
  $success = file_unmanaged_copy($file_real_path, self::getProjectRealPath($file_path, $project_root), FILE_EXISTS_REPLACE);
  if ($success) {
    watchdog('automatic_updates', '"@file" was successfully restored.', [
      '@file' => $file_path,
    ], WATCHDOG_INFO);
  }
  else {
    watchdog('automatic_updates', '"@file" failed restoration during rollback.', [
      '@file' => $file_path,
    ], WATCHDOG_ERROR);
  }
}