Broken argument replacements should trigger an E_USER_ERROR, not E_USER_DEPRECATED

Created on 15 March 2017, almost 8 years ago
Updated 4 March 2023, almost 2 years ago

If you have code like this:

drupal_set_message(t('My name is !name.', ['!name' => 'David']));

Drupal will not perform the replacement, and instead will output "My name is !name" to the screen. It will also trigger an error to notify developers about the problem.

However, if you have code like this:

drupal_set_message(t('My name is NAME.', ['NAME' => 'David']));

Drupal will still not perform the replacement (it will output "My name is NAME"). But instead of triggering an error, it will trigger an E_USER_DEPRECATED.

I don't think that makes sense. If it's broken code (not merely deprecated code) it should be an error just like the first case.

This issue is relatively minor, because it turns out Drupal logs/displays E_USER_DEPRECATED as if it were an error or a warning (so even if your development site is only configured to display errors/warnings to the screen, you'll probably still see it). That's presumably a bug though, and we shouldn't rely on it.

Also, my main interest in this issue is that it seems to be what the documentation in https://www.drupal.org/core/deprecation#how-unintended β†’ is based on. I think that documentation should be fixed as well as a followup to this issue - E_USER_DEPRECATED should only be used if something is deprecated but still works.

πŸ› Bug report
Status

Closed: duplicate

Version

10.1 ✨

Component
RenderΒ  β†’

Last updated about 8 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States David_Rothstein

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024