When using feedapi_mapper to map feed fields to one date field, and there could be missing some of "TO" dates, warnings are reported:
warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in /sites/all/modules/feedapi_mapper/mappers/feedapi_mapper_date.inc on line 405.
warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in /sites/all/modules/feedapi_mapper/mappers/feedapi_mapper_date.inc on line 407.
warning: date_format() expects parameter 1 to be DateTime, boolean given in /sites/all/modules/feedapi_mapper/mappers/feedapi_mapper_date.inc on line 409.
The resulting mapped nodes are OK.
Comments
Comment #1
iva2k commentedThe following patch removes these warnings. In this patch I added verification if date part is present.
Please review for committing to 6.x-1.x-dev.
Comment #2
aron novakThe patch seems to be fine, however I rerolled as a standard drupal patch format and added isset().
Comment #3
iva2k commentednag nag
Comment #4
alex_b commentedCommitted to 1.x and 2.x branches. Thank you and thanks for the reminder ;)
Comment #5
iva2k commented@alex_b,
Thanks for taking care of this. Sorry for reopening, but latest code with patch in #2 does not remove the warnings, which I received a bunch after updating. I should've tested it, but my code was still using patch in #1 until the recent update. It turns out that adding isset() in #2 passes on empty variables, but enclosed code still generates warnings on specific From-To dates in feeds.
Either remove isset(), or use patch in #1, which is equivalent. That fixed the warnings for good.
Comment #6
aron novakHowever, I assume replacing isset() to empty() should be also fine.
The patch should apply to both branches (likely with some offset)
Comment #7
iva2k commentedI edited by hand, and can confirm that !empty() in place of isset() removes the warnings.
Comment #8
aron novakshould be in FeedAPI mapper 2.0 beta 1
Comment #9
aron novakcommitted, thank you iva2k