Skip to content
Snippets Groups Projects

Issue #3231996: Ensure file system is writeable

2 files
+ 16
12
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -20,14 +20,24 @@ class WritableFileSystemValidator implements EventSubscriberInterface {
*/
protected $pathLocator;
/**
* The Drupal root.
*
* @var string
*/
protected $appRoot;
/**
* Constructs a WritableFileSystemValidator object.
*
* @param \Drupal\automatic_updates\PathLocator $path_locator
* The path locator service.
* @param string $app_root
* The Drupal root.
*/
public function __construct(PathLocator $path_locator) {
public function __construct(PathLocator $path_locator, string $app_root) {
$this->pathLocator = $path_locator;
$this->appRoot = $app_root;
}
/**
@@ -44,17 +54,10 @@ class WritableFileSystemValidator implements EventSubscriberInterface {
public function checkPermissions(UpdateEvent $event): void {
$messages = [];
$dir = $this->pathLocator->getProjectRoot();
if (!is_writable($dir)) {
$messages[] = $this->t('The project directory "@dir" is not writable.', ['@dir' => $dir]);
}
$web_root = $this->pathLocator->getWebRoot();
if ($web_root) {
$dir .= DIRECTORY_SEPARATOR . $web_root;
if (!is_writable($dir)) {
$messages[] = $this->t('The Drupal directory "@dir" is not writable.', ['@dir' => $dir]);
}
if (!is_writable($this->appRoot)) {
$messages[] = $this->t('The Drupal directory "@dir" is not writable.', [
'@dir' => $this->appRoot,
]);
}
$dir = $this->pathLocator->getVendorDirectory();
Loading