Closed (outdated)
Project:
Feeds
Version:
6.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Dec 2010 at 16:00 UTC
Updated:
16 Jun 2016 at 21:51 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
marcvangendI managed to fix this bug by replacing
strtotime()withdate_create()in both mappers/date.inc and plugins/FeedsParser.inc.While that works for me, I'm not 100% sure if this is the correct fix for every possible situation. I think we need to test this thoroughly so we don't break one thing while fixing another. One thing to learn from this, it that we need to be careful with code that is merely a workaround for PHP bugs.
Comment #2
kclarkson commentedI have looked everywhere regarding how to import date fields.
Could you help me out by listing the steps you took to get the date fields to import?
Thanks again,
Comment #3
marcvangendkclarkson: yes I can, but not here. This is a bug report, not a support forum. Please open a new forum topic or a support request issue for your question and send me a pm with the link.
Comment #4
marcvangendHere is a patch; I replaced two occurrences of strtotime() with date_create(). In mappers/date.inc, I also needed to check using empty():
This is needed because strtotime() returns false when given an empty string, while date_create interprets an empty string as 'now' and returns a vaild datetime object.
Comment #5
marcvangendOops - here is a patch.
Comment #6
johnvI tested your patch together with issue #831470, but your patch didn't work for me.
My source contains '00.00.0000' for a default/empty date. I can imagine other sources have dummy values as well.
I propose the following for your change in date.inc, introducing a 'contains only separators' test. You could also (better?) test for the opposite: contains_any_of('123456789')-test. But I couldn't find the proper php-function :-( .
Comment #7
marcvangend@johnv: AFAIK, the current code handles empty values perfectly, they just need to be empty. IMHO your code is fixing the problem in the wrong place. If your source contains dummy values, you can set them to an empty string in a custom parser, or you should try to change the source itself.
Comment #8
audua commentedmarcvangend, can you please direct me to where you solve Kclarkson's problem from above. I could get text field to import but not date field. Thanks in advance.
This is how my date xml looks
Thu, 02/25/2010 - 7:30pm
Thu, 02/25/2010 - 7:30pm
Comment #10
marcvangendaudua, I can't remember getting a pm from kclarkson, I never helped him solve his problem.
Comment #11
audua commentedmarcvangend, can you please help me with this then? I have an xml that I create with the views_datasource and the views_bonus modules. The xml is attached. I tried to map cck fields called title, location, body and date. But only title, location and body get mapped. CCK Date field is never mapped. I attached the mapping snapshot. I have also attached the settings for xpath xml parser. I don't know if it is a date format issue or I'm missing something. I even applied (manually) the patch from http://drupal.org/node/831470 from #5. Thanks in advance.
Comment #12
johnv@audua, I don't think your request anything to do with the initial issue and patch. Can you open a new 'support request'-issue for your problem, so we keep this thread dedicated to one subject? Thanx.
Comment #13
kclarkson commentedTo all,
Just wanted to give everyone a heads up that I got the date fields to import.
I am using excel to enter text from an old static HTML page.
For the date fields you need to use the custom format cells BEFORE to converting it to a csv file.
Comment #14
Taxoman commentedSubscribing
Comment #15
franzIs this patch still broken?
Comment #16
gaele commentedRecreated patch. I have no idea why the patch from #5 failed.
Comment #17
gaele commentedBTW I'm still looking for a solution for this for 7.x.
Comment #18
franzCan we avoid dealing with empty values for now? We should soon deal with it properly on #1107522: Framework for expected behavior when importing empty/blank values + text field fix.
Just replacing strtotime() looks great for now.
Comment #19
franzComment #20
twistor commented@franz, we can't avoid dealing with it at the moment. It just needs to follow current behavior, which is that empty values don't get set, unless it makes sense, like 0 for a number field.
Comment #21
twistor commentedComment #22
twistor commented