Issue Bug Closed

#106402Critical error in LocalizationUtility.php when accessing Backend Users in Spanish

Josué Gutiérrez Carrillo 03/20/25, 13:51 updated 09/01/26, 06:04

Description

In TYPO3 v12.4.28 with PHP 8.4, a critical error occurs in LocalizationUtility.php when accessing the “Usuarios de backend” module with the backend language set to Spanish. The issue seems to be caused by an invalid format specifier in a translation string.

Log output:

[CRITICAL] request=“422d3a6447131” component=“TYPO3.CMS.Core.Error.ProductionExceptionHandler”: Core: Exception handler (WEB: BE): ValueError, code #0, file /var/www/cms_typo3/vendor/typo3/cms-extbase/Classes/Utility/LocalizationUtility.php, line 91: Unknown format specifier “?”

Steps to reproduce

Set the TYPO3 backend language to Spanish.
Go to TYPO3 Backend > Usuarios de backend.
TYPO3 crashes with a ValueError: Unknown format specifier “?”.

Expected behavior

Instead of throwing a critical error, the system should handle incorrect placeholders gracefully.
Suggested Fix

Modify LocalizationUtility.php (lines 87-93) to validate placeholders before calling sprintf().

Current code:

if (is_array($arguments) && $arguments !== [] && $value !== null) {
return sprintf($value, …array_values($arguments)) ?: sprintf(
‘Error: could not translate key “%s” with value “%s” and %d argument(s)!’,
$key,
$value,
count($arguments)
);
}

Proposed fix:

if (is_array($arguments) && $arguments !== [] && strpos($value, ‘‘) !== false) {
preg_match_all(‘/
[a-zA-Z]/’, $value, $matches);
if (count($matches0) !== count($arguments)) {
return sprintf(‘Error: could not translate key “%s” with value “%s” and %d argument(s)!’, $key, $value, count($arguments));
}
}

Reviews 1

Files 2

History 89

  1. Georg Ringer commented and changed attached Bildschirmfoto 2025-03-20 um 15.27.54.png status New Needs Feedback <span data-processor="relativetime" data-value="2025-03-20T14:31:05+00:00" > 03/20/25, 14:31 </span>

    thanks for creating the issue. I couldn’t reproduce that on main or 12.4.28 using latest downloads of spanish backend
    Bildschirmfoto%202025-03-20%20um%2015.27.54.png

    can you check which string is the culprit and maybe also test on a clean system?

  2. Gerrit Code Review pushed patch set 1 for main to change 88661 status Needs Feedback Under Review <span data-processor="relativetime" data-value="2025-03-20T19:18:59+00:00" > 03/20/25, 19:18 </span>

  3. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-03-20T19:35:37+00:00" > 03/20/25, 19:35 </span>

    I would also love to understand which exact language key is causing the trouble here so that we might fix that on translation servers.

    I’ve created the linked patch with an alternate approach to your idea, by working with catching the possible two types of exceptions that sprintf() may throw. If you would be able to check out that patch, that would be great.

    Thanks for bringing this up, this is very helpful!

  4. Josué Gutiérrez Carrillo commented <span data-processor="relativetime" data-value="2025-03-21T08:55:57+00:00" > 03/21/25, 08:55 </span>

    Garvin Hicking wrote in #note-4:
    > I would also love to understand which exact language key is causing the trouble here so that we might fix that on translation servers.
    >
    > I’ve created the linked patch with an alternate approach to your idea, by working with catching the possible two types of exceptions that sprintf() may throw. If you would be able to check out that patch, that would be great.
    >
    > Thanks for bringing this up, this is very helpful!

    Hi Garvin,

    Thanks a lot for the quick fix! It’s working perfectly now. I hope it gets approved smoothly, and I’ll be looking forward to the next update.

    Best regards!