1

We are using Contao 4.7.7 which depends on Symfony, for some reason we are receiving the following fatal error out of nothing, not sure how this one came up.

On this event: fos_http_cache.pre_handle the Kernel passes a wrong Event

How to solve this issue?

Fatal error: Uncaught TypeError: Argument 2 passed to Symfony\Component\EventDispatcher\EventDispatcher::dispatch() must be an instance of Symfony\Component\EventDispatcher\Event or null, instance of FOS\HttpCache\SymfonyCache\CacheEvent given, called in /vendor/friendsofsymfony/http-cache/src/SymfonyCache/EventDispatchingHttpCache.php on line 164 and defined in /vendor/symfony/event-dispatcher/EventDispatcher.php:37

Stack trace:

  1. /vendor/friendsofsymfony/http-cache/src/SymfonyCache/EventDispatchingHttpCache.php(164): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('fos_http_cache....', Object(FOS\HttpCache\SymfonyCache\CacheEvent))

  2. /vendor/friendsofsymfony/http-cache/src/SymfonyCache/EventDispatchingHttpCache.php(100): Contao\ManagerBundle\HttpKernel\ContaoCache->dispatch('fos_http_cache....', Object(Symfony\Component\HttpFoundation\Request), NULL, 1)

  3. /web/app.php(58): in vendor/symfony/event-dispatcher/EventDispatcher.php on line 37

Pierrick Rambaud
  • 1,726
  • 1
  • 20
  • 47
  • In Symfony 5, the dispatch signature was changed from $eventName,$event to $event,$eventName=null. In Symfony 4, either way worked. I don't know anything about Contao but it looks like the Symfony dispatcher got updated to 5 while the rest of the code is still on 4. – Cerad Dec 09 '19 at 20:55
  • What do you mean by "out of nothing"? Have you updated any component? If yes, from which version to which? – Nico Haase Dec 12 '19 at 10:38

1 Answers1

1

This is a bug that occurs in Contao 4.7 with the most recent Symfony dependencies. You need to update to the most recent, currently supported Contao version (at the time of your post that would be Contao 4.8.5).

Contao 4.7 is not supported anymore. See the release plan for more information about the currently supported versions.

fritzmg
  • 2,494
  • 3
  • 21
  • 51