When an ad with a start and end date is expired (unpublished) via cron, it as republished, even though the current date is greater than the end date, and the ad should therefore remain unpublished.

What happens is that node_save() which is triggered by cron (with the correct value set for $node->status = 0) invokes the node_presave() hook which runs simpleads_node_presave() - this checks for a form field $node->field_ad_date[$node->language][0]['show_todate'] which doesn't exist when a node is loaded via node_load. So because this value does not exist, the module presumes there is no end date and sets the status to published.

I am working on a fix.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

foxtrotcharlie’s picture

Title: Ads with end date in the past are republished by cron (show_todate field does not exist in node_load » Ads with end date in the past are republished by cron (show_todate field does not exist in node_load)
foxtrotcharlie’s picture

Status: Active » Needs review
FileSize
1.4 KB

This patch finds another way to test whether or not an end date has been explicitly set.

When an ad is initially created, and the end date checkbox is left unchecked, when saved, the end date is set to the same value as the start date, so we can use this to test whether or not an end date was chosen. If they are the same, then we assume no end date was chosen, which we can then use to determine whether or not to continue publishing the ad.

skorzh’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Assigned: foxtrotcharlie » Unassigned
FileSize
456 bytes

Attached patch for 7.x-1.x version

Status: Needs review » Needs work

The last submitted patch, 3: simpleads-end_date-2455595-3.patch, failed testing.

skorzh’s picture

Status: Needs work » Needs review

Should be reviewed manually.

golddragon007’s picture

Status: Needs review » Reviewed & tested by the community

it seems it works

igorik’s picture

can be it imported/fixed into the module?

minnur’s picture

Status: Reviewed & tested by the community » Closed (won't fix)