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.

Comments

evgeny.chernyavskiy created an issue. See original summary.

evgeny.chernyavskiy’s picture

evgeny.chernyavskiy’s picture

Status: Needs work » Needs review
geoanders’s picture

@evgeny.chernyavskiy

Thanks for the patch. Change makes sense. I will get this added in.

  • 3e73cac committed on 8.x-1.x
    Issue #3281424: Type error in ScheduledMaintenanceSubscriber::...
geoanders’s picture

Assigned: evgeny.chernyavskiy » Unassigned
Priority: Major » Normal
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.