Blank 'Authored on' field on re-edit of pending revision
jromine - January 31, 2009 - 20:18
| Project: | Revision Moderation |
| Version: | 5.x-1.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Description
If you edit your pending revision of a node, the 'Authored on' field
is blank, causing the node created date to be reset when the form
is submitted.
Repeat by:
1. Add a new page with 'New Revisions in Moderation' checked; submit.
2. Edit the (pending revision of the) page; submit.
3. Edit (again) the page; observe 'Authored on' field is blank in the form.
node_form() calls node_object_prepare(), which populates the authored
on (node->date) field. With the late call to node_load() in the
'prepare' section of revision_moderation_nodeapi(), the node->date
field doesn't get populated for the loaded node/revision.

#1
This is a quick-fix patch.
#2
I cannot reproduce this bug using the steps you describe. Could you please clarify which type of user role you used when editing?
I did the following to test the bug:
Setting this as needs review for others to test.
#3
As I recall, this bug was difficult to track down. It happens when a user edits a node, the new revision remains unpublished, and the same user re-edits the same node (i.e., re-editing his/her previously unpublished revision).
#4
Aah... know I see it. Yes, the authored on field is indeed empty when editing your own revision once again.
I've been looking into this for an hour and the more I think of it I'm convinced that the
node_load($node->nid, $node->vid)in the prepare section ofrevision_moderation_nodeapi()is the wrong way to do it since the form and node objects has been populated with$node->date informationbefore that step. When we load the node again (actually the editing user's latest revision of the node) we overwrite the$node->date</date> information set by <a href="http://api.drupal.org/api/function/node_object_prepare/5">node_object_prepare()</a>. <code>node_load($node->nid, $node->vid)by itself does not set that information. Search fornode_object_preparein node.module to see what I mean.If you comment out the line
node_load($node->nid, $node->vid)from the prepare section you'll see that the$node->dateinformation exists in$node. It is set by node_object_prepare().Any ideas?
#5
Well, if I understand the code correctly, revision_moderation_nodeapi() is basically overriding which revision gets loaded, during a callback from node_object_prepare(), right? I think you'll have to use node_load() to load a specific revision.
I question the code setting node->created and node->date in node_object_prepare(). Perhaps that code should be in node_load(), or perhaps it should have its own API call (I think that's the correct fix, but I'm not a node.module expert).
I see a similar work-around to set node->date in blogapi_blogger_new_post(); having modules duplicate core code seems like a bad thing. On the other hand, since we're overriding the revision that gets loaded, maybe it's the responsibility of revision_moderation_nodeapi() to re-populate node->date.
#6
That's correct. You'll have to use
node_load()to load a specific revision. I feel the same, having modules duplicate core code does not seem like an acceptable solution.I found the closed issue #130186: Redirect when editing a node that have a pending revision describing the same bug. It includes another patch that feels more "safe" than the one we are discussing here. I have reopened that issue and I'm going to test the patch.
#7
Yeah, redirect to edit the pending revision is a much better fix.
#8
Setting this as duplicate of #130186: Redirect when editing a node that have a pending revision. Patch provided in that issue should be used.
#9
As noted before that the menu data is populated in nodeapi/prepare, this issue would probably explain why I'm seeing my menu assignment getting blanked out when editing a pending revision.