Cron loop seams to delete the row from scheduler table even when unpublish_on is defined.
Drupal 5.3 - MySQL 5.0.32-Debian_7etch1-log - PHP 5.2.2-0.dotdeb.0
Reproducing:
$NOW = 2007-11-13 18:22:00
Edit a node and add scheduling data:
Publish ON: 2007-11-13 18:20:04
Unpublish ON: 2007-11-14 18:31:04
*Select data from DB
mysql> select * from scheduler;
+--------+------------+--------------+----------+
| nid | publish_on | unpublish_on | timezone |
+--------+------------+--------------+----------+
| 153263 | 1194978004 | 1195065064 | 7200 |
+--------+------------+--------------+----------+
1 row in set (0.00 sec)
*run cron
*Select data from DB
mysql> select * from scheduler;
Empty set (0.00 sec)
It seems on line #240 it don't seem to get the variable:
//if this node is not to be unpublished, then we can delete the record
if ($n->unpublish_on == 0) {
db_query('DELETE FROM {scheduler} WHERE nid = %d', $n->nid);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | scheduler_unpublish_time_removed.patch | 2.24 KB | nterbogt |
| #1 | scheduler.patch | 905 bytes | tostinni |
Comments
Comment #1
tostinni commentedI think I nailed it.
The problem is from
scheduler_nodeapiin the "load" part.Current code add scheduler info in a
$node->schedulerwhich is an array.But everywhere in the module, it checks for info directly from the $node variable:
if ($node->unpublish_on == 0)etc...So here's a patch that correct the load part to make it consistent and add the correct variables.
Comment #2
nterbogt commentedSlightly different patch than the one above. This patch builds on the work of tostinni but follows the Drupal patch guidelines so that people know how to apply it.
Sorry tostinni, I had to manually apply your patch by editing the file rather than using the patch command.
Also, added an extra line to removed the nid from the results (which eventually gets put into the node structure) because this is duplicating data, which nobody should be doing anyway.
Had thoughts about writing a foreach loop to go through the database table columns and add them to the node, so you won't have to maintain this code if the tables change, but I'll leave this up to the developer.
Comment #3
AjK commentedhttp://drupal.org/cvs?commit=93935 Thanks!
Comment #4
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #5
davyvdb commentedI have ran into the same problem once again. The cause of the problem was the fact that cron runs as anonymous user. And anonymous users don't have access to schedule the (un)publishing of nodes.
The nodeapi load event checks to see if a user has access to (un)publishing nodes. This is not necessary!!! So to make this thing work here's the quick fix...
This is quick and dirty but it works for now here!!!
Comment #6
jgoldberg commentedI'm having the same problem. Can we look to getting a patch? (Is this module even getting maintained?)
Comment #7
AjK commentedYes, the module is maintained (you may have noticed a DRUPAL 6 release recently).
I have updated DRUPAL-5 and DRUPAL-6--1 branches to basically include Davy Van Den Bremt rework of hook_nodeapi($op == 'load').
If you could test this and get back to me that it works as expected then I will produce an official release.
If you don't know how to checkout the alterations from CVS then use these links to get them:-
DRUPAL 5 :-
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/scheduler/s...
DRUPAL 6 :-
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/scheduler/s...
Comment #8
imrook commentedI am also having this problem. I did some debugging and found that during the cron run, node_submit is called. scheduler_submit then promptly overwrites the existing timestamps with the following lines of code:
This happens because scheduler assumes that $node->publish_on and $node_unpublish_on are strings coming from the from. During the cron run, however, they are the actual timestamps. I added a simple is_numeric check to determine where the input was coming from. The code I'm using is the following:
While this fix stops the bleeding, I don't like it as a permanent solution. I think a better solution would have the data in a known state before nodeapi is called. This could be achieved using a custom validator or converting to a date string during nodeapi 'load'. I don't know the various use cases for this module well enough to determine which tactic is better. I will be keeping an eye on this thread though in the hopes that a permanent fix for this bug is implemented.
Comment #9
skiminki commentedOk, cron run doesn't call node_submit() anymore (see #230836: CCK date field shows blank after the node is published.), so is issue valid anymore? At least, I'm unable to reproduce it against current CVS 5.x head.
I'm marking this as fixed. Please reopen this issue or submit a new one if the problem still persists.
Comment #10
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.