Project:Feed Element Mapper
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

#1

Status:active» needs review

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.

AttachmentSize
feedapi_mapper_date_warning.2009-06-28.patch 1.49 KB

#2

Status:needs review» reviewed & tested by the community

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

AttachmentSize
504852_date_warning.patch 1.64 KB

#3

nag nag

#4

Status:reviewed & tested by the community» fixed

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

#5

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.

#6

Status:active» needs review

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

AttachmentSize
504852-6_date_warning.patch 1.18 KB

#7

Status:needs review» reviewed & tested by the community

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

#8

Priority:normal» critical

should be in FeedAPI mapper 2.0 beta 1

#9

Status:reviewed & tested by the community» fixed

committed, thank you iva2k

#10

Status:fixed» closed (fixed)

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