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
Files
3
@@ -48,27 +48,40 @@ class WritableFileSystemValidator implements EventSubscriberInterface {
}
/**
* Checks that the file system is writable.
* Wrapper around is_writable().
*
* @param \Drupal\automatic_updates\Event\UpdateEvent $event
* The event object.
* @param string $path
* The path to check.
*
* @return bool
* TRUE if the given path is writable, otherwise FALSE.
*
* @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
* false negatives/positives due to things like SELinux, exotic file
* 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 {
$messages = [];
if (!is_writable($this->appRoot)) {
if (!$this->isWritable($this->appRoot)) {
$messages[] = $this->t('The Drupal directory "@dir" is not writable.', [
'@dir' => $this->appRoot,
]);
}
$dir = $this->pathLocator->getVendorDirectory();
if (!is_writable($dir)) {
if (!$this->isWritable($dir)) {
$messages[] = $this->t('The vendor directory "@dir" is not writable.', ['@dir' => $dir]);
}
Loading