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

iva2k’s picture

Status: Active » Needs review
StatusFileSize
new1.49 KB

The 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.

aron novak’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.64 KB

The patch seems to be fine, however I rerolled as a standard drupal patch format and added isset().

iva2k’s picture

nag nag

alex_b’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 1.x and 2.x branches. Thank you and thanks for the reminder ;)

iva2k’s picture

Status: Fixed » Active

@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.

aron novak’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB

However, I assume replacing isset() to empty() should be also fine.
The patch should apply to both branches (likely with some offset)

iva2k’s picture

Status: Needs review » Reviewed & tested by the community

I edited by hand, and can confirm that !empty() in place of isset() removes the warnings.

aron novak’s picture

Priority: Normal » Critical

should be in FeedAPI mapper 2.0 beta 1

aron novak’s picture

Status: Reviewed & tested by the community » Fixed

committed, thank you iva2k

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.