Issue Task Closed

#102045The LocalizationUtility should handle ValueError Exceptions thrown by sprintf

Philipp Wrann 09/27/23, 08:39 updated 04/24/25, 14:54

Description

see https://forge.typo3.org/issues/102044
see https://www.php.net/manual/en/function.sprintf.php

Since PHP 8.0 sprintf throws ValueError Exceptions insteadof triggering a warning.

At the moment a ValueError is thrown and ultimately only catched by the RequestHandler, which results in a generic 500/503 Error page with a not so verbose error message (even in development).

It would be better, if the LocalizationUtility would catch ValueError Exceptions thrown by PHP, log them in a very verbose way (The translation string for the entity ‘{fullIdentifier}’ is malformed: {originalValueError}). It should then also take alternativeLanguageKeys into account (as fallback) and finally return a blank string so fallback handling can kick in.

Reviews 1

History 4

  1. Lina Wolf commented <span data-processor="relativetime" data-value="2025-04-24T08:40:27+00:00" > 04/24/25, 08:40 </span>

    I just had a use case which I think was related.

    ERROR] request="9b4fb39a4b131" component="TYPO3.CMS.Scheduler.Scheduler": Task failed to execute successfully. Class: Cobweb\ExternalImport\Task\AutomatedSyncTask, UID: 3, Code: 0, "4 arguments are required, 3 given" in /var/www/.../vendor/typo3/cms-extbase/Classes/Utility/LocalizationUtility.php at line 91- ArgumentCountError: 4 arguments are required, 3 given, in file /var/www/.../vendor/typo3/cms-extbase/Classes/Utility/LocalizationUtility.php:91 - {"taskClass":"Cobweb\\ExternalImport\\Task\\AutomatedSyncTask","taskId":3,"exception":"ArgumentCountError: 4 

    This argument count error in sprintf was breaking our automatic imports.

  2. Garvin Hicking commented and changed status New Closed <span data-processor="relativetime" data-value="2025-04-24T14:54:00+00:00" > 04/24/25, 14:54 </span>

    I’d prefer to close this as #106402 has some
    Discussion and a patch attached (which has negative votes), can we take it there?