Problem/Motivation
TypeError: Argument 1 passed to Drupal\scheduled_maintenance\EventSubscriber\ScheduledMaintenanceSubscriber::checkForScheduledMaintenance() must be an instance of Symfony\Component\HttpKernel\Event\RequestEvent, instance of Symfony\Component\HttpKernel\Event\GetResponseEvent given in Drupal\scheduled_maintenance\EventSubscriber\ScheduledMaintenanceSubscriber->checkForScheduledMaintenance() (line 70 of modules/contributed/scheduled_maintenance/src/EventSubscriber/ScheduledMaintenanceSubscriber.php).
This is caused by the RequestEvent type hint for checkForScheduledMaintenance() $event parameter. The issue is that RequestEvent was added to Symfony at some point in 4.x, and is not available in Symfony 3.x. Instance of GetResponseEvent is passed by DI instead.
Proposed resolution
Remove the type hint, change method documentation such that $event type hint is a union of GetResponseEvent and RequestEvent.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3281424-check-for-scheduled-maintenance-type-hint-type-error.patch | 907 bytes | evgeny.chernyavskiy |
Comments
Comment #2
evgeny.chernyavskiy commentedComment #3
evgeny.chernyavskiy commentedComment #4
geoanders commented@evgeny.chernyavskiy
Thanks for the patch. Change makes sense. I will get this added in.
Comment #6
geoanders commented