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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gorkagr created an issue. See original summary.

gorkagr’s picture

After 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

$language = $this->languageManager->getCurrentLanguage();
$default_url = Url::fromRoute('<front>', [], ['language' => $language])->toString(TRUE);
$response = new RedirectResponse($default_url->getGeneratedUrl());
$response = ['response' => $response];
.....
return $response['response'];

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.

pbattino’s picture

I confirm changes suggested in #2 work for me!

larisse’s picture

Status: Active » Needs review
FileSize
1023 bytes

Hi! I created a patch with the Proposed resolution by @gorkagr, in comment #2

lalit774’s picture

FileSize
738 bytes

I did not see above patch before upload this one. both are same

lalit774’s picture

FileSize
1.61 KB

#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];

jcnventura’s picture

Status: Needs review » Needs work

Overlooked 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.

  • jcnventura committed 290d709 on 2.x
    Issue #3223261 by lalit774, larisse, gorkagr, jcnventura: User error: "...
jcnventura’s picture

Status: Needs work » Fixed
gorkagr’s picture

Thnks for the quick fix :)
Best,

Status: Fixed » Closed (fixed)

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