When creating a new node the publishing options and entered revision information is not kept if the node edit form is reloaded. When editing an existing node, entered revision information is not kept. This causes unexpected behavior when the node form is a multi-step one, or e.g. javascript is disabled and the upload module is enabled and used.
Platform:
Drupal 6.3, Gentoo Linux, Apache 2.2.9, PHP 5.2.6-pl2-gentoo
Steps to reproduce:
1. Enable 'upload' module, disable Javascript in your browser.
2. Create a new node (any type will do), or edit an existing one, preferrably as site adminstrator
3. Customize the publishing options and revision information (enter a log etc)
4. Click the attach button (no need to actually upload a file).
Result:
The publishing options are reset to their defaults (if creating a new node), the revision information is reset to the default settings and the entered log is lost.
Expected behaviour:
The checked options should remain checked, the unchecked should remain unchecked. Any log message that is entered should be remembered.
I've created two patches to fix this issue. The first (node_remember_options) modifies node_object_prepare such that options are only changed if they are not already set. The second variant checks that the form was not submitted (in node_form), if it is then it does not prepare the node object again.
Both patches set the #default_value of the revision log to $node->log (if set).
I'm not sure which one would be the right approach, since modules may perhaps rely on the nodeapi 'prepare'/node_prepare hook every time the form is redisplayed. The second patch (node_donot_prepare_twice) will cause the node forms to only call prepare for nodes once over the lifetime of the form (until final submission). To me the second patch seems to be the most logical approach though, especially when taking note that the preview button also does not let the prepare hooks run a second time.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | node_donot_prepare_twice.patch | 716 bytes | haffmans |
| node_donot_prepare_twice.patch | 919 bytes | haffmans | |
| node_remember_options.patch | 1.34 KB | haffmans |
Comments
Comment #1
haffmans commentedSome information I forgot about the patches: they are against Drupal 6.3. I can recreate them against HEAD though, if necessary.
Edit: looks like the relevant code (node.pages.inc) hasn't changed in HEAD, so the patches should work for HEAD too.
Comment #2
haffmans commentedThis bug is still present in Drupal 7 (and 6.10). The revision log is now kept in D7, but the checkbox (to create a new revision) is not enabled. The Publishing options are also not remembered.
I've ported the second patch above (node_donot_prepare_twice) to D7, see attachment.
Note that this bug applies to anything that makes the node form multi-step form (without AJAX/AHAH), so it doesn't just occur when javascript is disabled in the browser. It's just the easiest testcase.
If the other patch is the better approach, I can port it too. Please comment.
Comment #3
haffmans commentedD6.3 -> D7
(Haven't checked, but I believe this bug still applies to Drupal 6.10 too)
Comment #4
cburschkaThis bug apparently pops up on wiki pages here on d.o too, where "preview changes" will delete the log message you entered,
Patch looks good and indeed applies to D7 and D6.
I think this one makes more sense than the other one, but I don't know enough about multi-page forms for an informed opinion.
Comment #5
dwwBefore this goes in, we should consider if #382634: Previewing multiselect taxonomy fields lose value on multistep node forms is ultimately the right fix here... That title is actually way more specific than the patch really is. Please test patch (currently #21 is your best bet) with this use-case and see if that solves it. Thanks!
Comment #7
Tor Arne Thune commentedI was not able to reproduce this on 7.0. In my opinion, this has been fixed elsewhere long ago.