function SiteConfigurationExcluder::makeDefaultSiteDirectoryWritable

Makes the staged `sites/default` directory owner-writable.

This allows the core scaffold plugin to make changes in `sites/default`, if needed. Otherwise, it would break if `sites/default` is not writable. This can happen because rsync preserves directory permissions (and Drupal tries to write-protect the site directory).

We specifically exclude `default.settings.php` and `default.services.yml` from Package Manager operations. This allows the scaffold plugin to change those files in the stage directory.

Parameters

\Drupal\package_manager\Event\PostCreateEvent $event: The event being handled.

See also

::excludeSiteConfiguration()

File

core/modules/package_manager/src/PathExcluder/SiteConfigurationExcluder.php, line 77

Class

SiteConfigurationExcluder
Excludes site configuration files from stage directories.

Namespace

Drupal\package_manager\PathExcluder

Code

public function makeDefaultSiteDirectoryWritable(PostCreateEvent $event) : void {
    $dir = $this->getDefaultSiteDirectoryPath($event->stage
        ->getStageDirectory());
    // If the directory doesn't even exist, there's nothing to do here.
    if (!is_dir($dir)) {
        return;
    }
    if (!$this->fileSystem
        ->chmod($dir, 0700)) {
        throw new FileException("Could not change permissions on '{$dir}'.");
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.