Problem/Motivation
Testing the dev module after upgrading from D8 to 9.5.4 and PHP8.1.14, I've encountered a few white screens of death that I should submit as issues. This is the first:
The website encountered an unexpected error. Please try again later.
Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("user") to generate a URL for route "entity.user.recurly_subscriptionlist". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 181 of core/lib/Drupal/Core/Routing/UrlGenerator.php).
Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute('entity.user.recurly_subscriptionlist', Object, Array, Array) (Line: 292)
Drupal\Core\Routing\UrlGenerator->generateFromRoute('entity.user.recurly_subscriptionlist', Array, Array, 1) (Line: 105)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('entity.user.recurly_subscriptionlist', Array, Array, ) (Line: 765)
Drupal\Core\Url->toString() (Line: 276)
Drupal\Core\Controller\ControllerBase->redirect('entity.user.recurly_subscriptionlist', Array) (Line: 53)
Drupal\recurly\Controller\RecurlySubscriptionReactivateController->reactivateSubscription(Object, 'latest')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
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: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 51)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
Select the "Reactivate" tab under Subscription in an account with a cancelled subscription. (This tab is only available under certain circumstances, such as when a subscription with a free trial has been cancelled but is still in the trial period.)
I know that devel can cause routing issues, so I should probably mention that I currently have it disabled. Apart from that, I'm not yet familiar enough with those issues to hazard a guess as to what's going on here.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork recurly-3348306
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
ethanstraffin commentedThe following may or may not be related to this issue, but I have encountered it immediately after successfully reactivating a subscription.
Warning: Undefined variable $entity_type_id in Drupal\recurly\Controller\RecurlySubscriptionReactivateController->reactivateSubscription() (line 53 of modules/contrib/recurly/src/Controller/RecurlySubscriptionReactivateController.php).
Drupal\recurly\Controller\RecurlySubscriptionReactivateController->reactivateSubscription(Object, 'latest')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
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: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 51)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment #5
eojthebraveThanks for pointing out these issues.
I found that the variable used to create the redirect route was `$entity_type_id` but the actual variable in the code is `$entity_type`. Fixing that fixed the redirect.
I also noticed this controller doesn't have any tests so I added tests for it. Which pointed out that in the case where it gets an error response from Recurly the controller would return no value. Which is invalid. So I removed the early return and let it proceed to the redirect. And the error message still gets displayed.
Comment #6
blakehall commentedThis looks good to me. RTBC.
Comment #8
eojthebraveThanks for reporting this issue @ethanstraffin. And for the quick review @blakehall. This has been merged into 4.x-dev.