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
Files
4
@@ -101,8 +101,8 @@ class SiteConfigurationExcluder implements EventSubscriberInterface {
* The event being handled.
*
* @throws \Drupal\Core\File\Exception\FileException
* If the permissions of either the live or staged `sites/default` cannot
* be determined, or cannot be changed on the staged `sites/default`.
* If the permissions of the live `sites/default` cannot be determined, or
* cannot be changed on the staged `sites/default`.
*/
public function syncDefaultSiteDirectoryPermissions(PreApplyEvent $event): void {
$staged_dir = $this->getDefaultSiteDirectoryPath($event->stage->getStageDirectory());
@@ -112,37 +112,16 @@ class SiteConfigurationExcluder implements EventSubscriberInterface {
}
$live_dir = $this->getDefaultSiteDirectoryPath($this->pathLocator->getProjectRoot());
// This is borrowed from \Symfony\Component\Filesystem\Filesystem::copy(),
// to ensure the correct permissions are preserved (chmod() requires
// permissions to be sent as an octal number, but fileperms() returns a
// decimal number, because PHP is just great).
$permissions = $this->getPermissions($staged_dir) | ($this->getPermissions($live_dir) & 0111);
$permissions = fileperms($live_dir);
if ($permissions === FALSE) {
throw new FileException("Could not determine permissions for '$live_dir'.");
}
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