-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Labels
Description
Description
Element -> parseDateAttribute() throws Exception if $formatting is NULL, but could default to 'auto'
When calling craft\feedme\services\Process->processFeed(...) from CLI using a JSON file generated by Craft export button.
In such a case where "$fieldInfo" does not list a $formatting attribute, craft\feedme\base\Element->parseDateAttribute(...) gets called with "$formatting == null" and throws an exception. It would instead be better if the default DateHelper::parseString(...) $formatting = 'auto' was used.
Steps to reproduce
- Export entries using Craft's default export button to create a JSON file
- Create a console controller with the following code:
where
$element = $processService->processFeed($key, $feedSettings, $processedElementIds, $data);
$data
contains entries parsed from the exported JSON file - Run the console command
- Observe the TypeError exception
Expected Behavior
- The date parsing should fall back to DateHelper::parseString() with 'auto' formatting when no formatting is specified.
Actual Behavior - TypeError is thrown: craft\feedme\helpers\DateHelper::parseString(): Argument CSRF Protection #2 ($formatting) must be of type string, null given, called in feed-me/src/base/Element.php on line 352
Additional info
- Craft version: 5.8.8
- PHP version: 8.2
- Database driver & version: MySQL 9.0.1
- Plugins & versions: Feed-Me 6.8.0