Ich arbeite gerade an einer Art Aboverlängerung mit automatisch generierten Bestellungen in Isotope: Wird ein Abo bestellt, wird das Enddatum (heute +ein Jahr) in ein Memberfeld geschrieben. Per Cron wird dann täglich geprüft, ob dieses Enddatum erreicht ist (und keine Kündigung eingegangen ist). Dann wird aus den Memberdaten und der ebenfalls dort gespeicherten Abo-Variante eine neue Bestellung erzeugt. Das funktioniert auch alles ganz gut.
Leider bekomme ich beim manuellen Ausführen des Cron-Jobs aber überall, wo unset($_SESSION['XYZ']) steht einen Session-Fehler:
Code:
[2023-11-01T12:38:32.257866+00:00] app.ERROR: RuntimeException: Failed to start the session because headers have already been sent by "/Users/a-v-l/www/contao/vendor/symfony/var-dumper/Dumper/AbstractDumper.php" at line 174. in /Users/a-v-l/www/contao/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:145 Stack trace:
#0 /Users/a-v-l/www/contao/vendor/symfony/http-foundation/Session/Session.php(61): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
#1 /Users/a-v-l/www/contao/vendor/contao/core-bundle/src/Session/LazySessionAccess.php(97): Symfony\Component\HttpFoundation\Session\Session->start()
#2 /Users/a-v-l/www/contao/vendor/contao/core-bundle/src/Session/LazySessionAccess.php(77): Contao\CoreBundle\Session\LazySessionAccess->startSession()
// Hier steht unset($_SESSION['FILES']) – was dann wohl den Fehler auslöst
#3 /Users/a-v-l/www/contao/vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Model/ProductCollection.php(1075): Contao\CoreBundle\Session\LazySessionAccess->offsetUnset('FILES')
// Hier wird das Produkt zur Bestellung hinzugefügt:
#4 /Users/a-v-l/www/contao/src/Cron/CronWorker.php(214): Isotope\Model\ProductCollection->addProduct(Object(Isotope\Model\Product\Standard), 1)
#5 /Users/a-v-l/www/contao/src/Cron/CronWorker.php(103): App\Cron\CronWorker->renewAbo(Array)
#6 /Users/a-v-l/www/contao/vendor/contao/core-bundle/src/Cron/CronJob.php(42): App\Cron\CronWorker->__invoke('web')
#7 /Users/a-v-l/www/contao/vendor/contao/core-bundle/src/Cron/Cron.php(131): Contao\CoreBundle\Cron\CronJob->__invoke('web')
#8 /Users/a-v-l/www/contao/vendor/contao/core-bundle/src/Controller/FrontendController.php(49): Contao\CoreBundle\Cron\Cron->run('web')
#9 /Users/a-v-l/www/contao/vendor/symfony/http-kernel/HttpKernel.php(163): Contao\CoreBundle\Controller\FrontendController->cronAction(Object(Symfony\Component\HttpFoundation\Request))
#10 /Users/a-v-l/www/contao/vendor/symfony/http-kernel/HttpKernel.php(75): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#11 /Users/a-v-l/www/contao/vendor/symfony/http-kernel/Kernel.php(202): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /Users/a-v-l/www/contao/vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php(86): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /Users/a-v-l/www/contao/vendor/symfony/http-kernel/HttpCache/HttpCache.php(481): Symfony\Component\HttpKernel\HttpCache\SubRequestHandler::handle(Object(Contao\ManagerBundle\HttpKernel\ContaoKernel), Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /Users/a-v-l/www/contao/vendor/symfony/framework-bundle/HttpCache/HttpCache.php(73): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)
#15 /Users/a-v-l/www/contao/vendor/symfony/http-kernel/HttpCache/HttpCache.php(454): Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true)
#16 /Users/a-v-l/www/contao/vendor/contao/manager-bundle/src/HttpKernel/ContaoCache.php(66): Symfony\Component\HttpKernel\HttpCache\HttpCache->fetch(Object(Symfony\Component\HttpFoundation\Request), true)
#17 /Users/a-v-l/www/contao/vendor/symfony/http-kernel/HttpCache/HttpCache.php(348): Contao\ManagerBundle\HttpKernel\ContaoCache->fetch(Object(Symfony\Component\HttpFoundation\Request), true)
#18 /Users/a-v-l/www/contao/vendor/symfony/http-kernel/HttpCache/HttpCache.php(226): Symfony\Component\HttpKernel\HttpCache\HttpCache->lookup(Object(Symfony\Component\HttpFoundation\Request), true)
#19 /Users/a-v-l/www/contao/vendor/friendsofsymfony/http-cache/src/SymfonyCache/EventDispatchingHttpCache.php(98): Symfony\Component\HttpKernel\HttpCache\HttpCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /Users/a-v-l/www/contao/public/index.php(44): Contao\ManagerBundle\HttpKernel\ContaoCache->handle(Object(Symfony\Component\HttpFoundation\Request))
#21 {main} [] []
Z.B. ist das in system/modules/isotope/library/Isotope/Model/ProductCollection.php:1075 der Fall. Wenn ich die Zeile auskommentiere läuft alles gut durch. Aber das kann ja keine saubere Lösung sein!
Hat jemand eine Idee?
Lesezeichen