Problem/Motivation

User deprecated function: Invalid placeholder (uid) in string: During rendering of embedded media: the media item with UUID "@uuid" does not exist. in Drupal\Component\Render\FormattableMarkup::placeholderFormat() (line 244 of core/lib/Drupal/Component/Render/FormattableMarkup.php).

This occurs when the placeholder is found in the copy in this case 'uid' is found but not allowed as a placeholder.

Steps to reproduce

Embed a remote video, delete the video, visit the page.

Proposed resolution

Prefix all placeholders (or remove)

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#8 3169832-8.patch2.53 KBjoelpittet
#2 3169832-2.patch2.95 KBjoelpittet

Comments

joelpittet created an issue. See original summary.

joelpittet’s picture

Status: Active » Needs review
StatusFileSize
new2.95 KB

Here's a possible solution, all the message arguments that are not valid are stripped out before they cause problems for FormattableMarkup

joelpittet’s picture

Issue summary: View changes
abu-zakham’s picture

Assigned: Unassigned » abu-zakham
abu-zakham’s picture

Thank you joelpittet,

I'll remove errorlog/errorlog.info.yml changes, I think it's added by mistake, you don't have to create a new patch

# Information added by Drupal.org packaging script on 2020-04-28
version: '8.x-1.0'
project: 'logging_alerts'
datestamp: 1588084459

Can you please explain how to reproduce this issue?

joelpittet’s picture

@abu-zakham Yes total mistake, I didn't have my project using the dev branch and copied the files changed/fixed.

So to reproduce this you just need to trigger a message that has uid the the text. In the issue summary I referenced where I saw it which was locally I don't have a media entity that was being embedded, so it triggered

$this->loggerFactory->get('media')->error('During rendering of embedded media: the media item with UUID "@uuid" does not exist.', ['@uuid' => $uuid]);

That is my hypothesis of what's going on at least... I was involved in FormattableMarkup's creation from format_string(), so you can blame me for this issue ;)

joelpittet’s picture

Something like this should trigger it if my theory is correct: \Drupal::logger('emaillog')->error('A string "uid" should not throw an invalid placeholder error: %test', ['%test' => 'Test']);

joelpittet’s picture

StatusFileSize
new2.53 KB

Removing the info.yml diff that snuck in there ;)

joelpittet’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

Bump since there was a new release

joelpittet’s picture

I guess the alternative is that the function can be a little more discerning which variables are passed along...

  • poker10 committed f426e018 on 2.0.x authored by joelpittet
    Issue #3169832 by joelpittet: Invalid placeholder (uid) in string
    
poker10’s picture

Assigned: abu-zakham » Unassigned
Status: Needs review » Fixed

I have tested this and the code removed unwanted placeholders. As a most straightforward fix looks good to me. Committed and pushed, thanks!

Status: Fixed » Closed (fixed)

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