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
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
- Write a Patch
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#7 | user_error_invalid-2641222-7.patch | 904 bytes | Alan D. |
| |||
#2 | user_error_invalid-2641222-2.patch | 657 bytes | thenchev |
|
Comments
Comment #2
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedThis should fix the error.
Comment #4
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedThanks!
Comment #5
Alan D. CreditAttribution: Alan D. commentedDoes 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>', [
Comment #6
BerdirI 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.
Comment #7
Alan D. CreditAttribution: Alan D. commentedTrue, untested patch :)
Comment #8
BerdirMake sense to me.
Comment #9
gillesv CreditAttribution: gillesv commentedIs "!" 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.
Comment #10
colanSee !placeholder removed from t() and format_string().
Comment #12
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedThanks Alan, rerolled and committed.