fix: fiabiliser les portées et médias publics

This commit is contained in:
Alexandre NOEL 2026-09-15 18:39:00 +02:00
commit 4493357590
11 changed files with 121 additions and 6 deletions

View file

@ -457,6 +457,7 @@ final class UpdateService
{
self::clearManagedCode($root);
self::copyManagedCode($source, $root);
self::normalizePublicCodePermissions($root . '/public');
foreach (['data', 'storage', 'public/media'] as $path) {
self::ensureDirectory($root . '/' . $path, 0770);
}
@ -466,6 +467,7 @@ final class UpdateService
{
self::clearManagedCode($root);
self::copyManagedCode($snapshot, $root);
self::normalizePublicCodePermissions($root . '/public');
}
private static function copyManagedCode(string $source, string $target): void
@ -558,6 +560,24 @@ final class UpdateService
}
}
private static function normalizePublicCodePermissions(string $publicRoot): void
{
if (!is_dir($publicRoot)) {
return;
}
@chmod($publicRoot, 0755);
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($publicRoot, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST,
);
foreach ($it as $item) {
if ($item->isLink()) {
continue;
}
@chmod($item->getPathname(), $item->isDir() ? 0755 : 0644);
}
}
private static function removeTree(string $path): void
{
if (is_link($path) || is_file($path)) {