-
Notifications
You must be signed in to change notification settings - Fork 1
fix: resolve 500 on /api/persons, session recursion and image OOM #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b98d032
fix: resolve 500 on /api/persons, session recursion and image OOM
LukaMrt ea85967
Migrate images
LukaMrt 6d75d7d
Fix format
LukaMrt 269f584
fix: add autoconf to Docker build deps for pecl imagick
LukaMrt 66248e9
fix: add build-base to Docker Alpine deps for pecl imagick
LukaMrt dbcda46
fix: address Copilot review issues
LukaMrt af12eb4
fix: stabilise e2e test for async autocomplete loading state
LukaMrt 32d82d0
Fix lint
LukaMrt 4e7f5d1
fix: use correct fullName casing in e2e tests (Henri DURAND)
LukaMrt 41ac54d
fix: family-navigation test uses /api/auth/me instead of /api/persons
LukaMrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-8.77 KB
(56%)
.../cache/avatar_full/uploads/avatars/04d04249801564c92579b9f8237de49a2c03e1a1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-9.16 KB
(80%)
.../cache/avatar_full/uploads/avatars/f85ab55cafa6746471f601a71c1d7ccc425a37c5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.04 KB
(56%)
...cache/avatar_thumb/uploads/avatars/04d04249801564c92579b9f8237de49a2c03e1a1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.58 KB
(78%)
...cache/avatar_thumb/uploads/avatars/f85ab55cafa6746471f601a71c1d7ccc425a37c5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Command; | ||
|
|
||
| use App\Repository\PersonRepository; | ||
| use App\Service\AvatarCacheService; | ||
| use Symfony\Component\Console\Attribute\AsCommand; | ||
| use Symfony\Component\Console\Command\Command; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
| use Symfony\Component\Console\Style\SymfonyStyle; | ||
| use Symfony\Component\Finder\Finder; | ||
|
|
||
| #[AsCommand( | ||
| name: 'app:deploy-reset', | ||
| description: 'Post-déploiement : vide les sessions et régénère le cache des avatars en WebP.', | ||
| )] | ||
| final class DeployResetCommand extends Command | ||
| { | ||
| public function __construct( | ||
| private readonly PersonRepository $personRepository, | ||
| private readonly AvatarCacheService $avatarCacheService, | ||
| private readonly string $projectDir, | ||
| ) { | ||
| parent::__construct(); | ||
| } | ||
|
|
||
| protected function execute(InputInterface $input, OutputInterface $output): int | ||
| { | ||
| $io = new SymfonyStyle($input, $output); | ||
|
|
||
| // ── 1. Vider les sessions ───────────────────────────────────────────── | ||
| $io->section('Invalidation des sessions'); | ||
|
|
||
| $sessionDir = $this->projectDir . '/var/sessions'; | ||
| $cleared = 0; | ||
|
|
||
| if (is_dir($sessionDir)) { | ||
| $finder = new Finder(); | ||
| $finder->files()->in($sessionDir); | ||
|
|
||
| foreach ($finder as $file) { | ||
| $path = $file->getRealPath(); | ||
|
|
||
| if ($path !== false && is_file($path) && unlink($path)) { | ||
| ++$cleared; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| $io->writeln(sprintf(' <info>✓</info> %d session(s) supprimée(s)', $cleared)); | ||
|
|
||
| // ── 2. Régénérer le cache des avatars ──────────────────────────────── | ||
| $io->section('Régénération du cache avatars (WebP)'); | ||
|
|
||
| $persons = $this->personRepository->findAll(); | ||
| $warmed = 0; | ||
| $skipped = 0; | ||
|
|
||
| foreach ($persons as $person) { | ||
| $picture = $person->getPicture(); | ||
|
|
||
| if ($picture === null) { | ||
| ++$skipped; | ||
| continue; | ||
| } | ||
|
|
||
| try { | ||
| $this->avatarCacheService->warmUp($picture); | ||
| $io->writeln(sprintf(' <info>✓</info> %s', $person->getFullName())); | ||
| ++$warmed; | ||
| } catch (\Throwable $e) { | ||
| $io->warning(sprintf('%s — %s', $person->getFullName(), $e->getMessage())); | ||
| } | ||
| } | ||
|
|
||
| $io->success(sprintf( | ||
| '%d avatar(s) régénéré(s), %d sans image, %d session(s) invalidée(s).', | ||
| $warmed, | ||
| $skipped, | ||
| $cleared, | ||
| )); | ||
|
|
||
| return Command::SUCCESS; | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.