I'm seeing intermittent errors such as the following one when web profiler is enabled. Disabling it fixes the problem. Tested with 1ddd7c5c642c17f8bb606369e9068ca8751cccb9.

The website encountered an unexpected error. Please try again later.
Recoverable fatal error: Argument 4 passed to Drupal\scheduler\SchedulerManager::__construct() must be an instance of Drupal\Core\Entity\EntityManager, instance of Drupal\webprofiler\Entity\EntityManagerWrapper given, called in x/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 281 and defined in Drupal\scheduler\SchedulerManager->__construct() (line 64 of modules/contrib/scheduler/src/SchedulerManager.php).
Drupal\scheduler\SchedulerManager->__construct(Object, Object, Object, Object, Object) (Line: 281)
Drupal\Component\DependencyInjection\Container->createService(Array, 'scheduler.manager') (Line: 181)
Drupal\Component\DependencyInjection\Container->get('scheduler.manager') (Line: 158)
Drupal::service('scheduler.manager') (Line: 390)
scheduler_cron()
call_user_func_array('scheduler_cron', Array) (Line: 382)
Drupal\Core\Extension\ModuleHandler->invoke('scheduler', 'cron') (Line: 199)
Drupal\Core\Cron->invokeCronHandlers() (Line: 124)
Drupal\Core\Cron->run() (Line: 79)
Drupal\Core\ProxyClass\Cron->run() (Line: 70)
Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate(Object, 'kernel.terminate', Object)
call_user_func(Array, Object, 'kernel.terminate', Object) (Line: 61)
Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(Object, 'kernel.terminate', Object) (Line: 116)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.terminate', Object) (Line: 124)
Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.terminate', Object) (Line: 79)
Symfony\Component\HttpKernel\HttpKernel->terminate(Object, Object) (Line: 32)
Stack\StackedHttpKernel->terminate(Object, Object) (Line: 615)
Drupal\Core\DrupalKernel->terminate(Object, Object) (Line: 22)

Comments

grahl created an issue. See original summary.

jonathan1055’s picture

Title: Scheduler throws exception with web profiler enabled » SchedulerManager throws exception on receiving EntityManagerWrapper from web profiler

Hi grahl,
Is that webprofiler? Are you using it as part of Devel?

Yes, we have just converted the Scheduler cron and one of the api hooks into a service, and Drupal\scheduler\SchedulerManager is new, committed on 13th April - details in #2651338: Create a service for the Scheduler API.

I don't know about the structure difference, regarding the expected
Drupal\Core\Entity\EntityManager versus the received
Drupal\webprofiler\Entity\EntityManagerWrapper

jonathan1055’s picture

Forgot to ask - what version of Core and Webprofiler/Devel are you using? There is a message about version compatibility on the webprofiler project page.

grahl’s picture

Sorry for not mentioning that, it's core 8.0.6 with devel ca8954d9611ed3f020e66aec0d3a6bf485a494b7

jonathan1055’s picture

I confirm that this is a problem with 8.0.4 and 8.0.6 with the devel module from 19th April.

idebr’s picture

This is fixed by casting the EntityManager dependency to its interface rather than a specific class, so it becomes swappable. This change is included in the patch at #2867272: Replace all usages of deprecated EntityManager

jonathan1055’s picture

The fix is also included in #2868553: Fix the code to adhere to Drupal Best Practice which is likely to be committed first.

idebr’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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