Skip to content
Snippets Groups Projects

Issue #3243422: Add a kernel test of WritableFileSystemValidator

Merged Issue #3243422: Add a kernel test of WritableFileSystemValidator
1 unresolved thread
Merged Ted Bowman requested to merge issue/automatic_updates-3243422:3243422-use-vfs into 8.x-2.x
1 unresolved thread
1 file
+ 5
18
Compare changes
  • Side-by-side
  • Inline
@@ -48,40 +48,27 @@ class WritableFileSystemValidator implements EventSubscriberInterface {
@@ -48,40 +48,27 @@ class WritableFileSystemValidator implements EventSubscriberInterface {
}
}
/**
/**
* Wrapper around is_writable().
* Checks that the file system is writable.
*
* @param string $path
* The path to check.
*
*
* @return bool
* @param \Drupal\automatic_updates\Event\UpdateEvent $event
* TRUE if the given path is writable, otherwise FALSE.
* The event object.
*
*
* @todo It might make sense to use a more sophisticated method of testing
* @todo It might make sense to use a more sophisticated method of testing
* writability than is_writable(), since it's not clear if that can return
* writability than is_writable(), since it's not clear if that can return
* false negatives/positives due to things like SELinux, exotic file
* false negatives/positives due to things like SELinux, exotic file
* systems, and so forth.
* systems, and so forth.
*/
*/
protected function isWritable(string $path): bool {
return is_writable($path);
}
/**
* Checks that the file system is writable.
*
* @param \Drupal\automatic_updates\Event\UpdateEvent $event
* The event object.
*/
public function checkPermissions(UpdateEvent $event): void {
public function checkPermissions(UpdateEvent $event): void {
$messages = [];
$messages = [];
if (!$this->isWritable($this->appRoot)) {
if (!is_writable($this->appRoot)) {
$messages[] = $this->t('The Drupal directory "@dir" is not writable.', [
$messages[] = $this->t('The Drupal directory "@dir" is not writable.', [
'@dir' => $this->appRoot,
'@dir' => $this->appRoot,
]);
]);
}
}
$dir = $this->pathLocator->getVendorDirectory();
$dir = $this->pathLocator->getVendorDirectory();
if (!$this->isWritable($dir)) {
if (!is_writable($dir)) {
$messages[] = $this->t('The vendor directory "@dir" is not writable.', ['@dir' => $dir]);
$messages[] = $this->t('The vendor directory "@dir" is not writable.', ['@dir' => $dir]);
}
}
Loading