- Issue created by @mfb
This is a followup from π Prevent the use of placeholders that cannot be converted into strings when creating logs Fixed .
Logic for determining if placeholder keys and values are valid is currently split between \Drupal\Component\Render\FormattableMarkup::placeholderFormat()
and \Drupal\Core\Logger\LogMessageParser::parseMessagePlaceholders()
.
In a nutshell, this logic is that the key should be a string starting with one of [@%:], and the value should be a string, integer, float or \Stringable
object (NULL is also accepted, but logs a deprecation notice).
To be determined, but new unified API methods for determining if a placeholder key and value are valid might be helpful, rather than splitting this logic between the render and logger subsystems.
Note that some additional logic could make sense as well:
Integers and floats presumably do not actually need to be escaped?
FormattableMarkup::placeholderFormat()
could log a warning and ignore non-\Stringable
objects, rather than throwing a TypeError
when the object is passed to htmlspecialchars()
via Drupal\Component\Utility\Html::escape()
?
Determine what API additions may be useful here, update the proposed resolution and develop a patch.
To be determined.
Active
11.0 π₯
Last updated