Node created date changed on node update

tiptoes - August 18, 2009 - 18:32
Project:Override Node Options
Version:6.x-1.9
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:duplicate
Description

Using this module, if a user is *not* shown the 'authoring information', we are finding that the created date is being changed to the current date/time. This mimics the action when Authoring Information -> 'Authored On' field is left blank.

I have tried this with node revisions, and without. This is a problem among multiple content types, and because we have Views sorting nodes by created date, it's causing some issues by changing the date.

I believe this line in the node.module is responsible ultimately (there is no $node->date)
$node->created = !empty($node->date) ? strtotime($node->date) : time();

Seems to be that the the node-date is blank when Authoring Information is restricted, and this module is not providing a hidden variable (or other method) for maintaining existing created time.

#1

Stefano - September 10, 2009 - 18:09

Hi, still no news on this bug?

I had a look at the module code and i found that tiptoes was right.
I did a little to change to line 257 of override_modes_options.module as follows:

if (($node->date !== $node->override_authored_on || !empty($node->override_authored_on)) && isset($node->override_authored_on)) {
$node->date = $node->override_authored_on;
$node->created = !empty($node->override_authored_on) ? strtotime($node->override_authored_on) : time();
}

As you may see I just added a parenthesis around the old conditions and then I added "&& isset($node->override_authored_on)"
in this way if the date field wasn't set nothing changes.

I'm testing it on my website and it seems to work correctly.
I would have made a patch but I'm new to drupal and have no idea on how things work here. Just wanted to to add my 2 cents to try to solve this bug. :)

#2

dicreat - September 23, 2009 - 11:25
Status:active» needs review

I have the same problem. Thanks Stefano, your solution works for me and I made patch for it.
Please review.

AttachmentSize
override_node_options.module.patch 674 bytes

#3

joachim - December 2, 2009 - 19:34

+++ override_node_options.module 2009-09-23 17:18:48.000000000 +0600
@@ -254,7 +254,7 @@ function _override_node_options_apply_ke
+        if (($node->date !== $node->override_authored_on || !empty($node->override_authored_on)) && isset($node->override_authored_on)) {

I think we can just check isset rather than both isset and empty. Wacky ol' PHP!

But also, I wonder if this would be fixed by #644820: Use the same form element names, not new ones.

I'm on crack. Are you, too?

#4

Dave Reid - December 27, 2009 - 22:53

#5

Dave Reid - December 27, 2009 - 22:53
Status:needs review» duplicate
 
 

Drupal is a registered trademark of Dries Buytaert.