Skip to content
Snippets Groups Projects

Issue #3363938: Package Manager should ignore default.settings.php and default.services.yml

Merged Issue #3363938: Package Manager should ignore default.settings.php and default.services.yml
1 unresolved thread
1 unresolved thread
@@ -86,25 +86,41 @@ class SiteConfigurationExcluder implements EventSubscriberInterface {
* The event being handled.
*
* @throws \Drupal\Core\File\Exception\FileException
* If the permissions of the live `sites/default` cannot be determined, or
* changed on the staged `sites/default`.
* If the permissions of the either the live or staged `sites/default`
* cannot be determined, or changed on the staged `sites/default`.
*/
public function syncDefaultSiteDirectoryPermissions(PreApplyEvent $event): void {
$live_dir = $this->getDefaultSiteDirectoryPath($this->pathLocator->getProjectRoot());
$staged_dir = $this->getDefaultSiteDirectoryPath($event->stage->getStageDirectory());
$original_permissions = fileperms($live_dir);
if ($original_permissions === FALSE) {
throw new FileException("Could not determine permissions for '$live_dir'.");
}
// This is borrowed from \Symfony\Component\Filesystem\Filesystem::copy().
$permissions = $this->getPermissions($staged_dir) | ($this->getPermissions($live_dir) & 0111);
// @see \Symfony\Component\Filesystem\Filesystem::copy() for another use
// of the 0111 bitmask.
if (!$this->fileSystem->chmod($staged_dir, $original_permissions & 0111)) {
if (!$this->fileSystem->chmod($staged_dir, $permissions)) {
throw new FileException("Could not change permissions on '$staged_dir'.");
}
}
/**
* Gets the current file permissions of a path.
*
* @param string $path
* The path to examine.
*
* @return int
* The current permissions of the path.
*
* @throws \Drupal\Core\File\Exception\FileException
* Thrown if the file permissions cannot be determined.
*/
private function getPermissions(string $path): int {
$permissions = fileperms($path);
if ($permissions === FALSE) {
throw new FileException("Could not determine permissions for '$path'.");
}
return $permissions;
}
/**
* Returns the full path to `sites/default`, relative to a root directory.
*
Loading