Hello,
I am trying to test this module and this is my scenario:
PHP 7.3, Core 8.6.9, Redis cache.
On a fresh Drupal install, enable monitoring, go to /admin/reports/monitoring:
TypeError: Argument 1 passed to Drupal\Core\Config\Entity\ConfigEntityBase::__construct() must be of the type array, object given, called in /project/www/modules/contrib/monitoring/src/SensorRunner.php on line 317 in Drupal\Core\Config\Entity\ConfigEntityBase->__construct() (line 112 of core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).
Drupal\Core\Config\Entity\ConfigEntityBase->__construct(Object) (Line: 317)
Drupal\monitoring\SensorRunner->getResultObject(Object) (Line: 169)
Drupal\monitoring\SensorRunner->runSensor(Object) (Line: 135)
Drupal\monitoring\SensorRunner->runSensors() (Line: 53)
Drupal\monitoring\Controller\SensorList->content()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
The website encountered an unexpected error. Please try again later.
Putting xdebug breakpoint in the code, and going step by step I don't see the problem and then it works...
So I go for example on /admin/reports/monitoring/sensors/update_contrib:
TypeError: Argument 1 passed to Drupal\Core\Config\Entity\ConfigEntityBase::__construct() must be of the type array, object given, called in /project/www/modules/contrib/monitoring/src/SensorRunner.php on line 310 in Drupal\Core\Config\Entity\ConfigEntityBase->__construct() (line 112 of core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).
Drupal\Core\Config\Entity\ConfigEntityBase->__construct(Object, Array) (Line: 310)
Drupal\monitoring\SensorRunner->getResultObject(Object) (Line: 169)
Drupal\monitoring\SensorRunner->runSensor(Object) (Line: 135)
Drupal\monitoring\SensorRunner->runSensors(Array, , 1) (Line: 78)
Drupal\monitoring\Form\SensorDetailForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 518)
Drupal\Core\Form\FormBuilder->retrieveForm('monitoring_sensor_config_details_form', Object) (Line: 275)
Drupal\Core\Form\FormBuilder->buildForm('monitoring_sensor_config_details_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
The website encountered an unexpected error. Please try again later.
And if I refresh /admin/reports/monitoring, same error as before.
I will try on PHP 7.2, if I don't post any comment it is because I would have obtained the same errors.
The problem is in monitoring/src/SensorRunner.php:
protected function getResultObject(SensorConfig $sensor_config) {
$result_class = '\Drupal\monitoring\Result\SensorResult';
if (!$this->forceRun && isset($this->sensorResultCache[$sensor_config->id()])) {
$result = new $result_class($sensor_config, $this->sensorResultCache[$sensor_config->id()]);
}
else {
$result = new $result_class($sensor_config);
}
return $result;
}
Thanks for any help.
Comments
Comment #2
grimreaperOn PHP 7.2.15, it is working like a charm.
Updating issue title.
Comment #3
berdirOur PHP 7.3/4 test are now passing.
Comment #4
grimreaperThanks for the feedback.
I guess the compatibility has been done in other issues.
Comment #5
berdirI actually didn't see or fix anything related to this error, that's why I didn't close it. But feel free to try again with the latest version.