Problem/Motivation
State is using the wrong class, may need to swap state for stateInterface. As that what's shown in the error logs. It seems like this error is prompted by an incompatibility with web-profiler.
To reproduce make sure to enable webprofiler on that environment.
Argument 2 passed to Drupal\acquia_connector\Form\SpiChangeForm::__construct() must be an instance of Drupal\Core\State\State
- public function __construct(ConfigFactoryInterface $config_factory, RequestStack $request, State $state) {
+ public function __construct(ConfigFactoryInterface $config_factory, RequestStack $request, StateInterface $state) {I am seeing that the error is occuring at line 33, called in line 45 of /mnt/www/html/utcclouddev/docroot/modules/contrib/acquia_connector/src/Form/SpiChangeForm.php:
33 public function __construct(ConfigFactoryInterface $config_factory, State $state) {
34 parent::__construct($config_factory);
35
36 $this->state = $state;
37 }Steps to reproduce
Update to 3.0.3 version of acquia_connector and try to connect it with your account
API changes
Replace state for stateinterface
Error
A change in your site's environment has been detected. SPI data cannot be submitted until this is resolved. Please confirm the action you wish to take."
https://[domain]/admin/config/system/acquia-connector/environment-change
Gives the error
```
[19-Apr-2021 19:44:54 Europe/Skopje] TypeError: Argument 2 passed to Drupal\acquia_connector\Form\SpiChangeForm::__construct() must be an instance of Drupal\Core\State\State, instance of Drupal\webprofiler\State\StateWrapper given, called in /mnt/www/html/utcclouddev/docroot/modules/contrib/acquia_connector/src/Form/SpiChangeForm.php on line 45 in /mnt/www/html/utcclouddev/docroot/modules/contrib/acquia_connector/src/Form/SpiChangeForm.php on line 33 #0 /mnt/www/html/utcclouddev/docroot/modules/contrib/acquia_connector/src/Form/SpiChangeForm.php(45): Drupal\acquia_connector\Form\SpiChangeForm->__construct(Object(Drupal\webprofiler\Config\ConfigFactoryWrapper), Object(Drupal\webprofiler\State\StateWrapper))
#1 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(28): Drupal\acquia_connector\Form\SpiChangeForm::create(Object(Drupal\Core\DependencyInjection\Container))
#2 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/Controller/HtmlFormController.php(48): Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition('\\Drupal\\acquia_...')
#3 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/Controller/FormController.php(76): Drupal\Core\Controller\HtmlFormController->getFormObject(Object(Drupal\Core\Routing\RouteMatch), '\\Drupal\\acquia_...')
#4 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#5 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#6 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#7 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#8 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#9 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#10 /mnt/www/html/utcclouddev/vendor/symfony/http-kernel/HttpKernel.php(151): call_user_func_array(Object(Closure), Array)
#11 /mnt/www/html/utcclouddev/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#12 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /mnt/www/html/utcclouddev/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /mnt/www/html/utcclouddev/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /mnt/www/html/utcclouddev/vendor/asm89/stack-cors/src/Asm89/Stack/Cors.php(49): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /mnt/www/html/utcclouddev/docroot/modules/contrib/purge_queuer_url/src/StackMiddleware/UrlRegistrar.php(168): Asm89\Stack\Cors->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /mnt/www/html/utcclouddev/docroot/modules/contrib/shield/src/ShieldMiddleware.php(91): Drupal\purge_queuer_url\StackMiddleware\UrlRegistrar->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\shield\ShieldMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /mnt/www/html/utcclouddev/docroot/modules/contrib/devel/webprofiler/src/StackMiddleware/WebprofilerMiddleware.php(38): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /mnt/www/html/utcclouddev/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /mnt/www/html/utcclouddev/docroot/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /mnt/www/html/utcclouddev/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#25 {main} request_id="v-f303653e-a136-11eb-a1ea-0f2c1e029c6c"
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3210423_4.patch | 3.46 KB | bernardm28 |
| #9 | 3210423_2.patch | 2.86 KB | bernardm28 |
Issue fork acquia_connector-3210423
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
bernardm28 commentedComment #3
bernardm28 commentedComment #4
bernardm28 commentedComment #5
bernardm28 commentedComment #6
luke.leberWhile I cannot reproduce this on our particular site, I wholeheartedly agree that the constructor should be typehinted with an interface unless there is a compelling reason to not do so.
I believe that this is an incompatibility with the webprofiler module. The solution is as you mention, to use an interface rather than concrete implementation.
Comment #7
utcwebdev commentedPHP 7.3 + MySQL 5.6 test passes, but 7.4 + 5.7 fails. Might be specific to the environment? We are deploying 3.0.3 and this patch to our Dev and Test environments for more troubleshooting.
Comment #8
utcwebdev commented@Luke.Leber We also feel webprofiler incompatibility is part of the problem. We have webprofiler running in our Local and Dev environments, but not in Stage and Prod. We're not seeing the same issue in Stage with 3.0.2.
Comment #9
bernardm28 commentedComment #10
bernardm28 commentedComment #11
bernardm28 commentedhttps://stackoverflow.com/questions/60412946/laravel-trying-to-access-ar...
According to PHP-Doc this is a Backwards Incompatible Change in PHP 7.4
https://www.php.net/manual/de/migration74.incompatible.php#migration74.i...
The patch works but it could be updated to pass that Backwards Incompatible Change in PHP 7.4.
Comment #12
bernardm28 commentedComment #14
bernardm28 commentedComment #15
bernardm28 commentedComment #16
bernardm28 commentedComment #17
bernardm28 commentedComment #18
bernardm28 commentedComment #19
japerry