Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
After upodating to alpha9, when clicking on logout, the following error appears:
User error: "response" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core/lib/Drupal/Core/Render/Element.php).
Drupal\Core\Render\Element::children(Array, 1) (Line: 402)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
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: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
I have just gone back to alpha8 and just confirmed that logout is OK in the previous release
Steps to reproduce
Login with the openid client (I have generic)
then log out
the error appears and the url remains /user/logout
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#6 | 3223261-6.patch | 1.61 KB | lalit774 |
Comments
Comment #2
gorkagr CreditAttribution: gorkagr commentedAfter checing the changes in between alpha8 and alpha9 (https://git.drupalcode.org/project/openid_connect/-/compare/2.0.0-alpha8...), it might be related to those done in OpenIDConnectRedirectController::redirectLogout().
We have now inside the if this:
$response = ['response' => $response];
but later on the function returns $response directly. We also have a$response = new RedirectResponse($default_url->getGeneratedUrl());
outside the if (in line 284)Should we instead have
to avoid having the mentioned error in #1 and to have standarised $response everywhere? (it seems to work, no error in logout with both changes.
Comment #3
pbattino CreditAttribution: pbattino commentedI confirm changes suggested in #2 work for me!
Comment #4
larisse CreditAttribution: larisse at CI&T commentedHi! I created a patch with the Proposed resolution by @gorkagr, in comment #2
Comment #5
lalit774 CreditAttribution: lalit774 as a volunteer commentedI did not see above patch before upload this one. both are same
Comment #6
lalit774 CreditAttribution: lalit774 as a volunteer commented#4 patch does not work for me. I have updated with #6 and tested. It is working fine for me. It is the same method proposed @gorkagr and implemented by @larisse.
It seems to me response is object, then we converted to array. Later we used as object again.
$response = new RedirectResponse($default_url->getGeneratedUrl());
$response = ['response' => $response];
So I have updated by new variable and it work like a charm.
$response = new RedirectResponse($default_url->getGeneratedUrl());
$response_array = ['response' => $response];
Comment #7
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedOverlooked that I was changing the variable being used below as the function return.. It needs to be a variable, as it is passed to the alter hook, but it can't be the same variable name.
@gorkagr suggestion was OK, but I don't think it is the solution.
Comment #9
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedComment #10
gorkagr CreditAttribution: gorkagr commentedThnks for the quick fix :)
Best,