Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseString() error #1287

Closed
jmauzyk opened this issue Apr 18, 2023 · 6 comments
Closed

parseString() error #1287

jmauzyk opened this issue Apr 18, 2023 · 6 comments
Assignees
Labels

Comments

@jmauzyk
Copy link

jmauzyk commented Apr 18, 2023

Description

Running into an error when trying to import a string representation of a date to an element's Post Date. Date strings follow the format 2023-04-18 10:00:00. Getting the following error and stack trace:

2023-04-18 18:41:48 [queue.ERROR] [TypeError] TypeError: craft\feedme\helpers\DateHelper::parseString(): Argument #2 ($formatting) must be of type string, null given, called in /var/www/html/vendor/craftcms/feed-me/src/base/Element.php on line 334 and defined in /var/www/html/vendor/craftcms/feed-me/src/helpers/DateHelper.php:24
Stack trace:
#0 /var/www/html/vendor/craftcms/feed-me/src/base/Element.php(334): craft\feedme\helpers\DateHelper::parseString('2007-01-01 10:5...', NULL)
#1 /var/www/html/vendor/craftcms/feed-me/src/elements/CommerceProduct.php(496): craft\feedme\base\Element->parseDateAttribute('2007-01-01 10:5...', NULL)
#2 /var/www/html/vendor/craftcms/feed-me/src/base/Element.php(107): craft\feedme\elements\CommerceProduct->parsePostDate(Array, Array)
#3 /var/www/html/vendor/craftcms/feed-me/src/services/Process.php(364): craft\feedme\base\Element->parseAttribute(Array, 'postDate', Array)
#4 /var/www/html/vendor/craftcms/feed-me/src/queue/jobs/FeedImport.php(99): craft\feedme\services\Process->processFeed(7, Array, Array)
#5 /var/www/html/vendor/yiisoft/yii2-queue/src/Queue.php(246): craft\feedme\queue\jobs\FeedImport->execute(Object(craft\queue\Queue))
#6 /var/www/html/vendor/yiisoft/yii2-queue/src/cli/Queue.php(162): yii\queue\Queue->handleMessage('2214831', 'O:34:"craft\\fee...', '2400', '1')
#7 /var/www/html/vendor/yiisoft/yii2-queue/src/cli/Command.php(146): yii\queue\cli\Queue->execute('2214831', 'O:34:"craft\\fee...', '2400', '1', '4069')
#8 [internal function]: yii\queue\cli\Command->actionExec('2214831', '2400', '1', '4069')
#9 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#10 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#11 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('exec', Array)
#12 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(87): yii\console\Controller->runAction('exec', Array)
#13 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\queue\Command->runAction('exec', Array)
#14 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('queue/exec', Array)
#15 /var/www/html/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('queue/exec', Array)
#16 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('queue/exec', Array)
#17 /var/www/html/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest(Object(craft\console\Request))
#18 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#19 /var/www/html/craft(13): yii\base\Application->run()

Steps to reproduce

  1. Set a string with the above format to be imported into element's Post Date.
  2. Run import, error shows in logs.

Additional info

  • Craft version: 4.4.7.1
  • PHP version: 8.2.3
  • Database driver & version: PostgreSQL 14.6
  • Plugins & versions: Feed Me 5.1.2
@jmauzyk jmauzyk added the bug label Apr 18, 2023
@i-just i-just self-assigned this Apr 19, 2023
@i-just
Copy link
Contributor

i-just commented Apr 19, 2023

Hi, thanks for getting in touch. I’m having a hard time reproducing this error. Could you please share a snippet of your feed that triggers this error and maybe a screenshot from the mapping screen that shows the options you selected for the post date?

@jmauzyk
Copy link
Author

jmauzyk commented Apr 19, 2023

@i-just Below is a snippet of the XML feed showing the date layout and a screenshot of the settings. This error does not occur in Craft 3, only in Craft 4. If it makes a difference, the element type for the feed is Commerce Product. Let me know if there's any additional info I can provide to help.

<?xml version="1.0" encoding="UTF-8"?>
<products>

  <product>
    <Product_Name___EN><![CDATA[Nitrile Mechanic's Gloves]]></Product_Name___EN>
    <Post_Date><![CDATA[2017-11-17 13:49]]></Post_Date>
    ...
  </product>

</products>

Screenshot 2023-04-19 at 9 41 13 AM

@i-just
Copy link
Contributor

i-just commented Apr 20, 2023

Perfect, thank you. That helped me reproduce the issue. PR has been raised.

@i-just
Copy link
Contributor

i-just commented Apr 20, 2023

One more thing - once released, you will need to re-save your feed so that the date fields get the formatting option (currently missing from the mapping screen for Commerce Products).

@angrybrad
Copy link
Member

Fixed in #1296 for the next v4 and v5 releases.

@angrybrad
Copy link
Member

We just released Feed Me 4.6.3. and 5.1.3 with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants