Silex Uncaught TypeError TerminateEvent instead of PostResponseEvent
jahir opened this issue · 6 comments
With current master (commit 2047524) on PHP 8.0.12, I get this for every page load in my error log. The page seems to load fine though...
PHP Fatal error: Uncaught TypeError: Silex\Application::Silex\{closure}(): Argument #1 ($event) must be of type Symfony\Component\HttpKernel\Event\PostResponseEvent, Symfony\Component\HttpKernel\Event\TerminateEvent given, called in /var/www/patrikx3/gitlist/gitlist/vendor/symfony/event-dispatcher/EventDispatcher.php on line 230 and defined in /var/www/patrikx3/gitlist/gitlist/src/Silex/src/Silex/Application.php:302
Stack trace:
#0 /var/www/patrikx3/gitlist/gitlist/vendor/symfony/event-dispatcher/EventDispatcher.php(230): Silex\Application->Silex\{closure}()
#1 /var/www/patrikx3/gitlist/gitlist/vendor/symfony/event-dispatcher/EventDispatcher.php(59): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
#2 /var/www/patrikx3/gitlist/gitlist/vendor/symfony/http-kernel/HttpKernel.php(98): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
#3 /var/www/patrikx3/gitlist/gitlist/src/Silex/src/Silex/Application.php(504): Symfony\Component\HttpKernel\HttpKernel->terminate()
#4 /var/www/patrikx3/gitlist/gitlist/src/Silex/src/Silex/Application.php(479): Silex\Application->terminate()
#5 /var/www/patrikx3/gitlist/gitlist/public/index.php(32): Silex\Application->run()
#6 {main}
thrown in /var/www/patrikx3/gitlist/gitlist/src/Silex/src/Silex/Application.php on line 302
something is wrong, because you can test online it works:
https://gitlist.tk
https://gitlist.patrikx3.com
no error. how can you reproduce it?
something is wrong, because you can test online it works: https://gitlist.tk https://gitlist.patrikx3.com no error. how can you reproduce it?
It works here, too. In the browser, there is no apparent issue, the error appears only in the php error log.
The pages look exactly the same as the ones on your server, apart from the repositories, of course. I even moved all the repositories to another directory to make sure there is nothing wrong with them, but the outcame was the same. The same error message is logged when I browse a repositories contents, so it's not really related to the repository index.
Regarding the error message, I think it's comprehensible: Silex/Application.php:302 subscribes to KernelEvents::TERMINATE, but the event handler function expects a PostResponseEvent:
$this->on(KernelEvents::TERMINATE, function (PostResponseEvent $event) use ($callback, $app) {...
/var/www/gitlist.patrikx3/vendor/symfony/http-kernel/HttpKernel.php:98
dispatches a TerminateEvent
object (as one would expect) with its KernelEvents::TERMINATE
event, so the mentioned exception is raised.
Searching for these events, I found this in the Symfony http-kernel changelog:
5.0.0
-----
...
* removed `PostResponseEvent`, use `TerminateEvent` instead
So I changed both mentions of PostResponsEvent
to TerminateEvent
in Silex/Application.php
, and now the error is gone. We could send this to the Silex people, but Silex is EOL since June 2018... but upgrading to Symfony 4 and Flex is probably not that simple, right?
yeah, it is inline the repo, it is upgraded alredy, but error are existing. checking the log..
ok udpated and released.