Description:
When you edit a content type and check 'create new revision', that setting doesn't seem to be remembered when you go and create/edit a node of that type. It always appears to be unchecked. I would expect it to be set to whatever it is in the 'edit content type' form.

Platform:
Drupal 7.0-alpha1, Apache 2.2.11 (Win32), PHP 5.2.10, MySQL 5.1.35

Steps to reproduce:

  1. Basic install of Drupal 7 head (use all defaults)
  2. Edit content type: Article
  3. Check 'create new revision' (under 'publishing options') and save
  4. Add new Article node

Result:
In the node edit form, 'create new revision' is not checked.

Expected behaviour:
The 'create new revision' setting for the content type should be retained as the default on the node edit form.

After saving the node, if I edit it again, the 'create new revision' checkbox is still unchecked.

I also then installed the 'blog' module and tested with that content type -- with the same result.

Comments

alexjarvis’s picture

Version: 7.0-alpha1 » 7.x-dev
Assigned: Unassigned » alexjarvis

Behavior is general, not specific to alpha1.

I'll take a look at this.

alexjarvis’s picture

Status: Active » Needs review
StatusFileSize
new1.63 KB
new834 bytes

This is actually only an issue for users with the 'administer content' permission. The problem stems from the use of #states to automatically check the 'Create new revision' box when a revision log message is entered. Unfortunately #states also merrily unchecks the checkbox when the log is empty, which always is initially.

I propose two alternative solutions to this:

1) Simply remove the #states entirely from the process. This restores D6's behavior and auto revisioning node types will have 'Create new revision' checked as expected. Patch.

2) Replace #states with a more sophisticated script that never unchecks the 'Create new revision' checkbox, but does automatically check it if the log is filled in. Patch.

Personally I prefer option #2 as it is the most in keeping with the intent of using #states and has the most natural behavior.

alexjarvis’s picture

Priority: Normal » Critical

Had a discussion this weekend that convinced me this issue is a performance regression and should therefore be reprioritized critical.

kpander’s picture

Apologies for taking so long to respond... I'll try and find time this weekend to test the patch (thanks!).

alexjarvis’s picture

Happy to help:)

You might also want to look at #728090: "Revision information" can have incorrect summary; it's a similar issue, but it's new to D7 rather than a regression.

arhak’s picture

I ran into this
this is what I was about to open in an issue:

if a site-builder sets up a content type with "Create new revision" he/she is expecting that a new revision will be created by default regardless of editors having administer nodes permission
but if the editor have such permission and doesn't navigates to the revision log, then the checkbox will be unchecked (if JS is enabled on his/her browser)
which is an inconsistent and undesirable behavior

catch’s picture

Status: Needs review » Needs work
+      //Check the create new revision checkbox if it exists, isn't already checked, and the log is filled.

Please add a leading space for the comment.

I'm not qualified to review js but option #2 seems preferable.

alexjarvis’s picture

Status: Needs work » Needs review
StatusFileSize
new1.67 KB

Option #2 with a leading space in front of the comment, per catch's request.

kpander’s picture

#8 Seems to work, at least from my perspective. Great! (Tested against 7.0 alpha 3)

Status: Needs review » Needs work

The last submitted patch, issue-685784-2-better-script-2.patch, failed testing.

alexjarvis’s picture

Status: Needs work » Needs review
StatusFileSize
new1.63 KB

Last patch got some Windows line ending somehow, rerolled.

@kpander - Should this be marked reviewed?

aspilicious’s picture

Wrap comment, it exceeds 80 characters

alexjarvis’s picture

StatusFileSize
new1.66 KB

Wrapped comment.

kpander’s picture

Status: Needs review » Reviewed & tested by the community

@alexj: Looks good!

sun’s picture

Status: Reviewed & tested by the community » Needs work

A couple of white-space issues in this patch. But anyway...

I guess we should take a step back. Is this behavior correct after all?

The checkbox only appears for administrators. The current code tries to auto-enable the checkbox if the log message is non-empty. That's a nice little tweak, but we do not have such magic anywhere else in Drupal (yet). I didn't even know that this code here exists.

Therefore, to fix this bug, we only set #states if $node->revision is not enabled. In turn, this means that when $node->revision is enabled (by default or not), there is no magical auto-enabling at all.

However, I'm not sure whether I like/support this behavior in the first place. So dropping that #states property entirely is a valid option 2).

alexjarvis’s picture

Status: Needs work » Needs review

Agreed, removing #states entirely is a perfectly valid fix to this issue. Ultimately it's just a question of what the default behavior should be.

If we just drop #states, my previous patch should be usable. If we want auto-checking/unchecking then I'm happy to clean up any remaining white-space issues and roll another patch. I just need to know which approach we want to take.

Setting back to "needs review" to stimulate discussion.

sun’s picture

StatusFileSize
new1.31 KB

There you go.

sun’s picture

StatusFileSize
new1.26 KB

sorry, I forgot about progressive enhancement modularity form alteration clusterfuck.

So this one it is.

alexjarvis’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.