I found that there still is a problem when running cron to publish nodes: If an unpublish date is set, it will be wiped out, too. On the other hand, I find it not too good, to wipe out any publishing date as it could be used for documentation purposes (when has this node been published?). When analyzing the code (I'm a PHP and Drupal newbe) I found out, that it is not necessary for the module to delete the schedule record as it always uses the status attribute of the node as an additional search criterion. So I changed the code in the following manner:
1. when any publishing date is set, the status field ("Published") is set accordingly on update (currently status is always set to 0 awaiting a cron job to set it accordingly)
2. the schedule record is never deleted automatically, the user must reset the fields in the node manually.
Here are the changes:
* lines 173 to 179 deleted
* inserted after line 183:
// (un)publish_on has got the highest priority, so set published status accordingly
$utc = time() + $node->timezone ;
if ( $node->publish_on != NULL && $node->unpublish_on != NULL ){
if ( $node->publish_on <= $utc && $utc <= $node->unpublish_on ) {
$node->status = 1; // published
}
else {
$node->status = 0; // unpublished
}
}
else if ($node->publish_on != NULL && $node->publish_on <= $utc ) {
$node->status = 1; // published
}
else if ($node->unpublish_on != NULL && $node->unpublish_on < $utc ) {
$node->status = 0; // unpublished
}
* lines 239 to 246 deleted
* line 265 deleted
And now it works fine!
But I think, it would be better to integrate date fields into the core for the status attribute and for the promote attribute. When you then check any of these two fields the corresponding "beginning" date can be set to the current time unless already set. Thus it will be possible out of the box, to define the time intervall the node is published and/or promoted to the front page.
Nevertheless: Great work!
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | scheduler_history_3.patch | 16.64 KB | sirkitree |
Comments
Comment #1
AjK commentedThese fields won't end up in Core (that's just the way things work around here). If you want to supply aletrations please supply a patch.
Comment #2
sirkitree commentedThis issue is over two years old, so I'm highjacking it for the D6 version. This is a problem if you have any other module that might key off of this data. Here's the use case:
I have a node with scheduling enabled and auto_nodetitle. Auto_nodetitle is using the publish_on and unpublish_on dates to give the node a title. When this data is removed and the node is saved the title becomes corrupt/inaccurate.
I understand the reason that this data is wiped out, but I think that removing this data is more of a workaround than a 'fix' for the 'publish must be in the future' issue. Trying to find the issue where this was the decided way to go...
Comment #3
sirkitree commentedLooks like there is some work on this over at #782710: Views Calendar integration
Comment #4
sirkitree commentedThis patch is being moved over here, split out from #782710: Views Calendar integration.
Comment #5
sirkitree commentedPertinent comments from #782710: Views Calendar integration from Eric:
Comment #6
sirkitree commentedmaybe this is just a preference, but I've never seen this split in core before so I'm not sure it's completely kosher here.
Eric said that these should be part of a separate patch. We might even want to remove the comment clarifications/capitalizations as part of a general cleanup patch.
Personally I don't think it hurts to use drupal_write_record here as this is new code, not refactoring, but Eric might have a different opinion.
This one is def a re-write so should be reverted per Eric's comments.
Personally I think this format for a query is MUCH easier to read, but we might need approval to keep it this way since all of the other queries are structured as one-liners.
Using $scheduler instead of $node and $node instead of $n is a great improvement and i thin make sense to do in this patch since the original query is changing.
Again, may need approval on formatting.
As mentioned before, operating on $node instead of $n is highly recommended.
Powered by Dreditor.
Comment #7
eric-alexander schaefer commentedThe removal of the publish_on field on publishing is not a workaround of forbidden past dates. The fields already got removed long before past dates were forbidden. If a history should be kept the whole data design must be changed or the old values must be pushed into separate fields. I am not really satisfied with this design, but I also do not have the time to change it right away. It will be a gradual process. Maybe I will even move such a change to a 2.x branch, because scheduler is widely used today and I do not want to put all the users at risk. There are actually many things I want to change as time permits. Please don't hold your breath...
Thanks a lot for commenting on codys patch. I will have a look at it at the weekend.
Comment #8
eric-alexander schaefer commentedClosing this, because it is actually an really old issue which is not really related to the problem at hand. I will create a new issue for changing the whole data storage. For a lot of stuff I want to do I need a different db layout (normalized). I don't know yet how it will look like because the most obvious normalized schema will not be easy to use for views integration. Watch out for the new issue...
Comment #9
jonathan1055 commentedFor reference, here is the db change issue that Eric has created #1006766: Normalize and extend schema