Nodes don't expire on cron run
aaronbauman - April 16, 2009 - 15:10
| Project: | Node Expire |
| Version: | 6.x-2.03 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs work |
Description
Here's the problem: (from node_expire.rules.inc)
function node_expire_set_expired($nids, $set = FALSE) {
static $nid_no = array();
if (empty($close)) {
$nid_no[] = $node->nid;
}
else {
if ($nids = array_diff($nids, $nid_no)) {
db_query('UPDATE {node_expire} SET expired = 1
WHERE nid IN ('. implode(',', $nids) .')');
}
}
}What the heck is $close?
This code will always fail because $close will always be empty.
I would submit a patch, but I'm not sure what this is supposed to do...
I'm unfamiliar with Rules hooks, but is this a half-finished Rules action callback?

#1
I'm not familiar with Rules either, but I'm guessing that instead of $close is should be $set (since that is being passed to the function but isn't being used). So it looks like this:
function node_expire_set_expired($nids, $set = FALSE) {static $nid_no = array();
if (empty($set)) {
$nid_no[] = $node->nid;
}
That raised an error about the the first argument to array_diff() not being an array, so I made the following addition at line 19 in node_expire.module:
function node_expire_cron() {if ($query = db_query('SELECT n.nid FROM {node} n
JOIN {node_expire} ne ON n.nid = ne.nid
WHERE ne.expired = 0 AND ne.expire <= %d', time())) {
$nids = array(); /** ADDED THIS LINE **/
while ($node = db_fetch_object($query)) {
$nids[] = $node->nid;
This worked for my site, but it's a little bit of guess-work.
#2
Here's a patch for the previous comment, soliciting feedback.
#3
Is there perhaps an update on the errors or a new version please?
Same here, nodes do not expire and errors on cron jobs.
#4
Subscribing, greetings, Martijn