format_plural() in watchdog give redundant t() calls

Created on 4 December 2016, over 8 years ago
Updated 20 May 2025, about 5 hours ago

In function redirect_purge_inactive_redirects() the watchdog is called with a call to format_plural(). This causes the following problems:
- multiple t() calls
- cluttering the translation table by a translated strings per quantity and language
- the dblog contains incomprehensible messages if the message is created in one of the languages of the site I don't understand.

This simple change will do the trick:
Old:
watchdog('redirect', format_plural(count($rids), 'Removed 1 inactive redirect from the database.', 'Removed @count inactive redirects from the database.'));
New:
$messages = array(1 => 'Removed 1 inactive redirect from the database.', 2 => 'Removed @count inactive redirects from the database.');
watchdog('redirect', $messages[format_plural(count($rids), 1, 2)]);

Note:
Not all languages have 1 as the number with a different text. I am not an expert on this subject but possibly it should read:
$messages = array(1 => 'Removed @count inactive redirect from the database.', 2 => 'Removed @count inactive redirects from the database.');

✨ Feature request
Status

Closed: outdated

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands promes

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