I use Drupal 5 and has just installed Scheduler. When I enabled the Scheduler feature on a page, the system displays the node on the home page (assuming it's sticky). However when I click on it and access the content, it says access denied. I check under "Content Management" and find the node status is "not published" .
Question 1: The time on "Publish On" and "Unpublish On" were set correctly. I even waited couple hours to make sure it refresh. No matter how many times I check the publish option, the system unchecks it.
Question 2: If a node is scheduled to publish at a later time, why does it show up on the page as one of its listing.
Comments
Comment #1
ajk commentedFAQ: ensure you have setup cron.
As to why an "unpublished node" shows up, that's your Drupal, nothing to do with Scheduler.
Comment #2
cylan97 commentedThanks. Issued fixed.
Comment #3
cylan97 commentedLet me give you more details. I assigned a taxonomy term (e.g. HR) to this node and added a published and unpublished time.
I encountered 2 issues:
1) The node was published successfully. But it did not show up on HR page. The node status was "published" under "Content Management > Content", but since the taxonomy term was lost after running cron, it did not show up on the HR page. Is this a bug?
2) After #1, the same node failed to unpublish itself. If I re-enter a "unpublished on", the node will unpublish. It looks to me that Scheduler module works only when either "published on" or "unpublished on" is entered. NOT BOTH. Please clarify.
Thanks.
Comment #4
ajk commentedScheduler works for both settings. And as far as taxonomy is concerned, Scheduler ha snothing to do with that either. All scheduler does is changed the "status" flag on the node. If other things are "happening" then I'd think you have a bug elsewhere. It's just you don't see the outcome till scheduler publishes the node.
Comment #5
cylan97 commentedThank you. I have modified some of the codings in "scheduler.module" to fix these issues:
1) Issue: scheduler does not work when both "published on" and "unpublished on" are filled.
Solution: Scheduler delete the whole record from "Scheduler" table once the node was published even though "unpublished has values. In function scheduler_cron(), i changed from "== 0" to "<0":
//if this node is not to be unpublished, then we can delete the record
if ($node->unpublish_on < 0) {
db_query('DELETE FROM {scheduler} WHERE nid = %d', $node->nid);
}
2) Issue: Taxonomy term disappeared after the node was published / unpublished.
Solution: In function scheduler_cron(), it is better to update the "node" table directly instead of using node_save(). When node_save() is used, other nodeapi, (category / taxonomy for example) will also be called (http://api.drupal.org/api/HEAD/function/node_save). Since category / taxonomy does have any values under this circumstances, original value will be deleted from the term_node table.
while ($node = db_fetch_object($nodes)) {
$node = node_load($node->nid);
// $node->changed = $node->utc_publish_on;
// $node->status = 1;
// node_save($node);
db_query('UPDATE {node} SET status=1, changed=%d WHERE nid=%d', time(), $node->nid);
.
.
.
// node_save($node);
db_query('UPDATE {node} SET status=0, changed=%d WHERE nid=%d', time(), $node->nid);
Since Category / Taxonomy is now the core of Drupal 5, more and more people will have the same issue. Scheduler module might need to be modified. I am very new to Drupal and understand it is NOT GOOD change the module directly. If I can make it themeable on my template.php, please let me know. Thanks.
Comment #6
ajk commentedPoint one sounds like a bug. However, lets keep "one bug / one issue" please. I have created http://drupal.org/node/154795 for this bug.
Point two. Sorry, but I reject this as a "Bug" in Scheduler. You may have fixed it in Scheduler but something else is wrong here and I'll explain. If you look back over Scheduler history it did in fact publish and un-publish nodes via directly setting/clearing the status flag. However, a previous patch went in that pointed out the "correct way" was to use the API. By using node_load() followed by a node_save() should work just fine. If taxonomy values are lost it's because node_load() didn't load them (I may be wrong here, maybe I have to do something extra to load a node entirely, do you know?).
Anyway, the reason for changing from direct db access to API was exactly so other modules can react to the event (a change in status in this case). So it seems something else isn't playing ball on this somewhere in the chain of things.
If you load a node, you should be able to save it, plain and simple.