Comment's are defining a TwigReference Object in the template and it's getting translated through t() which passes it's args to format_string and needs an array.
Warning: strtr() [function.strtr]: The second argument is not an array in format_string() (line 1563 of core/includes/bootstrap.inc).
format_string('by !author on !date', Object)
t('by !author on !date', Object)
__TwigTemplate_d9c5ed3b99d9a3bc5231873f2a8462bc->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
twig_render_template('core/themes/stark/templates/node/node.html.twig', Array)
theme('node', Array)
drupal_render(Array)
drupal_render(Array)
drupal_render(Array)
drupal_render(Array)
drupal_render(Array)
render(Array)
twig_render(Object)
__TwigTemplate_596c0f2c055a0217f4af771691495974->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
twig_render_template('core/themes/stark/templates/system/page.html.twig', Array)
theme('page', Array)
drupal_render(Array)
drupal_render_page(Array)
Drupal\Core\EventSubscriber\ViewSubscriber->onHtml(Object)
Drupal\Core\EventSubscriber\ViewSubscriber->onView(Object)
call_user_func(Array, Object)
Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'kernel.view', Object)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.view', Object)
Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\HttpKernel->handle(Object, 1, 1)
Symfony\Component\HttpKernel\Kernel->handle(Object)
Comments
Comment #1
joelpittetThinking just casting the TwigReference in the t() function to an array since it implements ArrayObject
Thoughts?
Comment #2
dasjoi have updated the patch to use the interface
ArrayAccessinstead ofArrayObject.the problem here seems to be array type hinting being semi-compatible with objects that implement
ArrayAccess.we can see the semi-compatibility by the fact that the
TwigReferencegets passed through just fine, until it hits strtr().a grep in core for "
array $args" reveals that currently 38 functions declare this kind of type hinting, asformat_stringdoes.we might want to deal with this is in core directly, as it might not be a twig issue on its own.
e.g: "How to deal with
ArrayAccesswhen using array type hinting?"maybe related #1590150: Add ArrayAccess support to drupal_render()
Comment #3
dasjotagging for sprint
Comment #4
joelpittetYeah your patch make things cleaner, nice work. And I agree, it should go in core.
Comment #5
zakiya commentedWorked For me. I committed this to the front-end branch and will submit a patch for Drupal 8 HEAD.
Comment #6
alexrayu commentedIt supposed to be an array always, so can just have
$args = (array) $args;Why is it marked "needs work"?
Comment #7
joelpittet@alexrayu, there may be a better solution up the call stack but I agree with you, this should really be taken care of and the solution at #2 has my vote because it explicit to what it's fixing.
Straight casting may be too much of a blanket solution and may hide other problems of incorrect objects passed by accident.
Contrived example:
Changing this to needs review and bumping priority. #2 ftw?
Comment #8
star-szrSee #1916834: Twig implementation: passing array to set tag creates a TwigReference object, this should be tackled in the core queue :)
Comment #9
star-szrComment #10
jwilson3remove old tags (this one was only used on two ancient issues).