Problem/Motivation

Whenever I go to "Manage Display"
http://example.com/admin/config/people/accounts/display
I receive the following error:

User error: Invalid placeholder (!example) in string: Example: !example in Drupal\Component\Render\FormattableMarkup::placeholderFormat() (line 240 of core/lib/Drupal/Component/Render/FormattableMarkup.php).

Here's the backtrace:

Drupal\Component\Render\FormattableMarkup::placeholderFormat('Example: !example', Array)
Drupal\Core\StringTranslation\TranslatableMarkup->render()
Drupal\Core\StringTranslation\TranslatableMarkup->__toString()
implode('', Array)
Drupal\Core\Template\TwigExtension->safeJoin(Object, Array, '')
__TwigTemplate_f821c77039c217f90bf7a8f976486c27a1fbd3d077f048bd0be538f78a56fbe7->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
Drupal\Core\Template\TwigEnvironment->renderInline('{{ summary|safe_join("") }}', Array)
Drupal\Core\Render\Element\InlineTemplate::preRenderInlineTemplate(Array)
call_user_func(Array, Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1)
__TwigTemplate_98cf6ee9c325be56e5f6e2b50b209532e42534eaeb86ca76b1fbc0eee1a03602->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
__TwigTemplate_5476a84226f3edefca4c1a7dce64542dd8db5ceb2e74ef5dcac5a9cba7d00802->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
twig_render_template('core/themes/stable/templates/admin/field-ui-table.html.twig', Array)
Drupal\Core\Theme\ThemeManager->render('field_ui_table', Array)
Drupal\Core\Render\Renderer->doRender(Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array, )
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
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)

Proposed resolution

Fix the invalid placeholder.

Remaining tasks

  1. Write a Patch

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

davidwbarratt created an issue. See original summary.

thenchev’s picture

Status: Active » Needs review
FileSize
657 bytes

This should fix the error.

  • webflo committed 32c5baf on 8.x-1.x authored by Denchev
    Issue #2641222 by Denchev: Fix invalid placeholder !example...
webflo’s picture

Status: Needs review » Fixed

Thanks!

Alan D.’s picture

Status: Fixed » Needs work
      $formatted = SafeMarkup::checkPlain(NameFormatParser::parse($example, $format));
      if (empty($formatted)) {
         $formatted = '<em>&lt;&lt;empty&gt;&gt;</em>';
       }
-      $summary[] = t('Example: !example', array(
-        '!example' => $formatted
-      ));
+      $summary[] = t('Example: @example', [
+        '@example' => $formatted
+      ]);

Does the EM tag get escaped here? Format using title only and test with names that have no title component.

Maybe EM all and remove EM from the empty. (Empty string could be == <<empty>>)
- $summary[] = t('Example: @example', [
+ $summary[] = t('Example: <em>@example</em>', [

Berdir’s picture

I don't think always em is right, that's there for highlighting that it is empty.

Either have a different t() for the empty case or mark the empty text as safe.

Alan D.’s picture

Status: Needs work » Needs review
FileSize
904 bytes

True, untested patch :)

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Make sense to me.

gillesv’s picture

Is "!" just not allowed anymore for placeholders in Drupal 8? It is not mentioned here: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Rend...

If so, it should be fixed throughout the module. "name.module" contains quite a few placeholders that use the exclamation mark. It would also seem desirable that the "required" field error message was "@name field is required.", so that it conforms with the default required-fields error. This is more consistent and requires less translation work.

colan’s picture

Is "!" just not allowed anymore for placeholders in Drupal 8?

See !placeholder removed from t() and format_string().

  • webflo committed c4cb537 on 8.x-1.x authored by Alan D.
    Issue #2641222 by Alan D., Denchev, webflo: Fix double escaping in...
webflo’s picture

Status: Reviewed & tested by the community » Fixed

Thanks Alan, rerolled and committed.

Status: Fixed » Closed (fixed)

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