-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Expected behavior
The customer detail view of a customer is shown in the backend
Actual behavior
The detail view cannot be shown because of an exception
Steps to reproduce
Using the following versions:
"pimcore/platform-version": "2024.4"
"pimcore/admin-ui-classic-bundle": "1.7.3"
"pimcore/customer-management-framework-bundle": "4.2.0"
"pimcore/pimcore": "11.5.1"
"nesbot/carbon": "2.72.6"
Create a Customer Data Object which has a date field, in our case the field birthday. Set the default locale of the application (Symfony Setting: framework.default_locale) to German (de), because the error does not occur if the default locale is in English.
The exception in our case:
RuntimeError: An exception has been thrown during the rendering of a template ("Could not parse '17. Januar 2025': Failed to parse time string (17. Januar 2025) at position 7 (u): The timezone could not be found in the database").
in vendor/pimcore/customer-management-framework-bundle/src/Resources/views/admin/customers/partials/detail.html.twig (line 25)
[etc...]
Cause: InvalidFormatException in vendor/nesbot/carbon/src/Carbon/Traits/Creator.php (line 91): Could not parse '17. Januar 2025': Failed to parse time string (17. Januar 2025) at position 7 (u): The timezone could not be found in the database
in vendor/nesbot/carbon/src/Carbon/Traits/Creator.php (line 91)
in vendor/nesbot/carbon/src/Carbon/Traits/Creator.php -> __construct (line 187)
n vendor/nesbot/carbon/src/Carbon/Traits/Creator.php :: rawParse (line 224)
in vendor/pimcore/customer-management-framework-bundle/src/View/Formatter/DefaultViewFormatter.php :: parse (line 146)
in vendor/pimcore/customer-management-framework-bundle/src/View/Formatter/DefaultViewFormatter.php -> formatDatetimeValue (line 94)
in vendor/pimcore/customer-management-framework-bundle/src/CustomerView/DefaultCustomerView.php -> formatValueByFieldDefinition (line 117)
in vendor/twig/twig/src/Extension/CoreExtension.php -> getDetailviewData (line 1871)
[etc...]
We searched in the code, and found that the error is in class DefaultCustomerView, where in line 117 the function formatValueByFieldDefinition is called with value "17. Januar 2025" of type string, which is then passed to Carbon::parse($value) at some point later:
$result[$vf->getLabelByFieldDefinition($fd)] = $vf->formatValueByFieldDefinition($fd, $value);