FYI. After upgrading the core from 8.0.3 to 8.0.4 I am seeing the following error when I load my (one and only) forum page (/forum/13). This error does not present itself on any of the Article, Basic, Form or View pages on this website.

Uninstalling Token 8.x-1.0-alpha2 appears to have resolved this issue for me.

Notice: Array to string conversion in Drupal\Component\Render\HtmlEscapedText->__construct() (line 37 of core/lib/Drupal/Component/Render/HtmlEscapedText.php).

Drupal\Component\Render\HtmlEscapedText->__construct(Array)
Drupal\Core\Utility\Token->replace('[current-page:title] | [site:name]', Array, Array)
Drupal\metatag\MetatagToken->coreReplace('[current-page:title] | [site:name]', Array, Array)
Drupal\metatag\MetatagToken->contribReplace('[current-page:title] | [site:name]', Array, Array)
Drupal\metatag\MetatagToken->tokenReplace('[current-page:title] | [site:name]', Array)
Drupal\metatag\MetatagManager->generateElements(Array, NULL)
metatag_get_tags_from_route()
metatag_page_attachments(Array)
Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Q2U2 created an issue. See original summary.

sachbearbeiter’s picture

Same error with 8.0.3 ...

MartinMa’s picture

... and same with 8.0.5 :-(

platinum1’s picture

We have the same issue or a variation thereof:

Notice: Array to string conversion in Drupal\Component\Render\HtmlEscapedText->__construct() (line 37 of core/lib/Drupal/Component/Render/HtmlEscapedText.php).

Drupal\Component\Render\HtmlEscapedText->__construct(Array) (Line: 209)
Drupal\Core\Utility\Token->replace('[current-page:title] | [site:name]', Array, Array) (Line: 45)
Drupal\metatag\MetatagToken->replace('[current-page:title] | [site:name]', Array, Array) (Line: 305)
Drupal\metatag\MetatagManager->generateElements(Array, NULL) (Line: 217)
metatag_get_tags_from_route() (Line: 67)
metatag_page_attachments(Array) (Line: 302)
Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array) (Line: 278)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 122)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 95)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 116)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 62)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 103)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 82)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 55)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 55)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 631)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

The error appears when an Anonymous User or an Authenticated User accesses forum posts. The error does not appear when the Admin accesses the same forum posts.
The Drupal version is 8.1.x-dev

platinum1’s picture

Priority: Normal » Major
platinum1’s picture

Title: "Array to string conversion in Drupal" error after upgrading from core 8.03 to 8.04 » "Array to string conversion in Drupal" in Forum

Updated the title, as the problem is not restricted to a D8.0.4 upgrade

fomenkoandrey’s picture

Сообщение об ошибке
Notice: Array to string conversion in Drupal\Component\Render\HtmlEscapedText->__construct() (line 37 of core/lib/Drupal/Component/Render/HtmlEscapedText.php).

drupal 8.0.5
i have this error, after updating the Token module to the last version.

Ashutosh.tripathi’s picture

FIxed this issue by adding below code snippet :

     if (!is_object($value) && isset($value['#markup'])) {
          $value = $value['#markup'];
      }

at line 204 in core/lib/Drupal/Core/Utility/Token.php

Ashutosh.tripathi’s picture

platinum1’s picture

Works for me on D8.2.x-dev :-)

Thank you @Ashutosh.tripathi

platinum1’s picture

Status: Active » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 9: notice_token_replacement-2675738-#8.patch, failed testing.

The last submitted patch, 9: notice_token_replacement-2675738-#8.patch, failed testing.

Berdir’s picture

Version: 8.x-1.0-alpha2 » 8.x-1.x-dev

What you posted is a core patch, not token module.

However, that is just a workaround. Some token returns a render array instead of a string, that is not valid.

I'm guessing that forum returns a render array, which might work when printed in twig but not in a token. We need to do that conversion where the current-page:title token is generated.

huzooka’s picture

The bug appears on user pages too if the current-page:title token is used. So, this seems to be a more generic token (i mean current-page:title) related error.

webflo’s picture

Berdir’s picture

Status: Needs work » Closed (duplicate)

Thanks.