From 155f06629d899a8b8c15e052be2c245574a92311 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Tue, 24 Nov 2026 17:33:21 +0100 Subject: [PATCH] [TASK] Collect garbage cycles only between tests The functional tests crashed randomly with a segmentation fault on PHP 8.2. Objects of earlier test instances, e.g. the Extbase ReflectionService, are destroyed by the garbage collector. The destructor of the ReflectionService writes the class schemata to the cache, which calls serialize(). If the garbage collector runs while another serialize() is in progress, the nested serialize() frees memory the outer one still uses. A PHPUnit extension disables the automatic garbage collection and collects the cycles after the set up of each test and after each test. Resolves: #899 Co-Authored-By: Claude Opus 5.5 --- Build/phpunit.xml.dist | 3 + Tests/PhpUnit/GarbageCollectionExtension.php | 58 ++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 Tests/PhpUnit/GarbageCollectionExtension.php diff --git a/Build/phpunit.xml.dist b/Build/phpunit.xml.dist index e77e1726..e5a87e24 100644 --- a/Build/phpunit.xml.dist +++ b/Build/phpunit.xml.dist @@ -17,6 +17,9 @@ stopOnSkipped="false" > + + + ../Tests/Functional/ diff --git a/Tests/PhpUnit/GarbageCollectionExtension.php b/Tests/PhpUnit/GarbageCollectionExtension.php new file mode 100644 index 00000000..be05ea32 --- /dev/null +++ b/Tests/PhpUnit/GarbageCollectionExtension.php @@ -0,0 +1,58 @@ +registerSubscribers( + new class implements PreparedSubscriber { + public function notify(Prepared $event): void + { + gc_collect_cycles(); + } + }, + new class implements FinishedSubscriber { + public function notify(Finished $event): void + { + gc_collect_cycles(); + } + }, + ); + } +}