Hi to all!
I've made some posts arround some problems that node expire module has when interacting with other modules, ie. i18n sync. Finally I found that there are other modules that copy nodes and update them. Every time this happens, almost every field is copied byte to byte as it appears on database tables, but node expire has a particularity: it saves the expiration date as a timestamp but the user always enters it as a date string. so the module processes the date and converts it to timestamp in node_expire.nodeapi.inc with the line:
$node->expire = strtotime($node->expire);
what Im suggesting (and Im putting it under consideration of module developers) is to make a small variation to consider the case when the value is passed as a timestamp. (Note that this works only for other modules, the validation of this module doesn't allow user to set a timestamp). my sugestion is to change on node_expire.nodeapi.inc this code:
case 'update':
case 'insert':
// has the expiration been removed, or does it exist?
if (isset($node->expire)) {
db_query('DELETE FROM {node_expire} WHERE nid = %d', $node->nid);
// should we create a new record?
if ($node->expire) {
$node->expire = strtotime($node->expire);
$node->expired = FALSE;
drupal_write_record('node_expire', $node);
}
}
break;
into this one
case 'update':
case 'insert':
// has the expiration been removed, or does it exist?
if (isset($node->expire)) {
db_query('DELETE FROM {node_expire} WHERE nid = %d', $node->nid);
// should we create a new record?
if ($node->expire) {
if(strtotime($node->expire))
$node->expire = strtotime($node->expire);
$node->expired = FALSE;
drupal_write_record('node_expire', $node);
}
}
break;
note that I added an extra condition to check if the value can be converted, and if not, I assume that the current value is the timestamp and leave it as it is.
I would love any comments and it would be great to hear sponsors opinion. Hope also that this could help some one
greetings
Comments
Comment #1
vikramy commentedWill look into this later this week.. Thanks for posting your solution.
Comment #2
serguitus commentedThanks for taking my suggestion into account. I hope it could be useful and you could add it to the knew release
Comment #3
jerry commentedI ran into a problem today where a Workflow transition was apparently mangling the expiration date field back to the null value (1969). Unsure what precipitated this, as the site had been working fine for a couple of years, though the timing of the release of Workflow 6.x-1.5 seems about right. The change above did fix the problem, so I assume that Workflow must have started copying node contents, too.
I echo the request that this fix, or something equivalent, be added to the next release.
Comment #4
vikramy commentedFixed.. Check out latest dev.. Thanks serguitus and jerry..