Loading module/Administration/src/Command/UpdateCommand.php +39 Changes for module/Administration/src/Command/UpdateCommand.php: 39 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -67,6 +67,12 @@ class UpdateCommand extends Command $bin = getcwd()."/bin/ose"; passthru("$bin update-code $args"); // Purge brute du cache : la config fusionnée mise en cache par l'ancienne version peut référencer // des classes qui n'existent plus après le composer install, ce qui empêcherait update-bdd de démarrer // (clear-cache ne peut pas servir ici, puisqu'il a lui-même besoin de démarrer l'application) $this->purgeCache($io, getcwd() . '/cache'); passthru("$bin update-bdd"); //Conclusion Loading @@ -78,4 +84,37 @@ class UpdateCommand extends Command return Command::SUCCESS; } private function purgeCache(SymfonyStyle $io, string $cacheDir): void { if (!is_dir($cacheDir)) { return; } $io->section('Purge du cache'); $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($cacheDir, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST ); $echecs = []; foreach ($iterator as $item) { $path = $item->getPathname(); $ok = ($item->isDir() && !$item->isLink()) ? @rmdir($path) : @unlink($path); if (!$ok) { $echecs[] = $path; } } if (empty($echecs)) { $io->writeln('Cache purgé'); } else { $io->warning( count($echecs) . ' élément(s) du répertoire cache n\'ont pas pu être supprimés (droits ?), ' . 'par exemple ' . $echecs[0] . '. Si la suite de la mise à jour échoue, videz manuellement le répertoire cache.' ); } } } No newline at end of file Loading
module/Administration/src/Command/UpdateCommand.php +39 Changes for module/Administration/src/Command/UpdateCommand.php: 39 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -67,6 +67,12 @@ class UpdateCommand extends Command $bin = getcwd()."/bin/ose"; passthru("$bin update-code $args"); // Purge brute du cache : la config fusionnée mise en cache par l'ancienne version peut référencer // des classes qui n'existent plus après le composer install, ce qui empêcherait update-bdd de démarrer // (clear-cache ne peut pas servir ici, puisqu'il a lui-même besoin de démarrer l'application) $this->purgeCache($io, getcwd() . '/cache'); passthru("$bin update-bdd"); //Conclusion Loading @@ -78,4 +84,37 @@ class UpdateCommand extends Command return Command::SUCCESS; } private function purgeCache(SymfonyStyle $io, string $cacheDir): void { if (!is_dir($cacheDir)) { return; } $io->section('Purge du cache'); $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($cacheDir, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST ); $echecs = []; foreach ($iterator as $item) { $path = $item->getPathname(); $ok = ($item->isDir() && !$item->isLink()) ? @rmdir($path) : @unlink($path); if (!$ok) { $echecs[] = $path; } } if (empty($echecs)) { $io->writeln('Cache purgé'); } else { $io->warning( count($echecs) . ' élément(s) du répertoire cache n\'ont pas pu être supprimés (droits ?), ' . 'par exemple ' . $echecs[0] . '. Si la suite de la mise à jour échoue, videz manuellement le répertoire cache.' ); } } } No newline at end of file