You are here

protected function ReadOnlyFilesystem::doReadOnlyCheck in Automatic Updates 8

Do the read only check.

Parameters

string $file_path: The filesystem to test.

string $file: The file path.

array $messages: The messages array of translatable strings.

\Drupal\Component\Render\MarkupInterface $message: The error message to add if the file is read only.

1 call to ReadOnlyFilesystem::doReadOnlyCheck()
ReadOnlyFilesystem::readOnlyCheck in src/ReadinessChecker/ReadOnlyFilesystem.php
Check if the filesystem is read only.

File

src/ReadinessChecker/ReadOnlyFilesystem.php, line 85

Class

ReadOnlyFilesystem
Read only filesystem checker.

Namespace

Drupal\automatic_updates\ReadinessChecker

Code

protected function doReadOnlyCheck($file_path, $file, array &$messages, MarkupInterface $message) {

  // Ignore check if the path doesn't exit.
  if (!is_file($file_path . DIRECTORY_SEPARATOR . $file)) {
    return;
  }
  try {

    // If we can copy and delete a file, then we don't have a read only
    // file system.
    if ($this->fileSystem
      ->copy($file_path . DIRECTORY_SEPARATOR . $file, $file_path . DIRECTORY_SEPARATOR . "{$file}.automatic_updates", FileSystemInterface::EXISTS_REPLACE)) {

      // Delete it after copying.
      $this->fileSystem
        ->delete($file_path . DIRECTORY_SEPARATOR . "{$file}.automatic_updates");
    }
    else {
      $this->logger
        ->error($message);
      $messages[] = $message;
    }
  } catch (FileException $exception) {
    $messages[] = $message;
  }
}