more from the patches i have on top of drupal cvs to get things to work right. This one fixes the problem where sort and mode don't get set correctly when users register.

CommentFileSizeAuthor
set_sort_and_mode.patch2.61 KBWesley Tanaka

Comments

Wesley Tanaka’s picture

Status: Active » Needs review
dries’s picture

Not sure this is the proper fix; I'd think this needs fixing in comment.module. After your patch, when the administrator changes the defaults, this will only affect new users and not existing users that never changed the defaults.

Wesley Tanaka’s picture

why are the columns even in the database then? oh, for the users that change the default...

hmm. that's a huge problem then.

Unfortunately, 0 is already used both by:
define('COMMENT_ORDER_NEWEST_FIRST', 0);
and by
define('COMMENT_CONTROLS_ABOVE', 0);

perhaps NULL would represent users that haven't touched their settings? the mode column would need to be modified to accept NULL.

Wesley Tanaka’s picture

I argue that this should get committed anyway.

Modulo the weirdness that occurs due to: http://drupal.org/node/40570

what you've described as happening after this patch already is what is happening today. This patch makes things no worse than things are today, and is probably good to have in the beta series until the "real fix" happens.

It looks like the only reason that things seem to work today is that most administrators must not change the default comment settings in the first place. Thus, all their users' "mode" and "sort" are set to COMMENT_MODE_FLAT_COLLAPSED and COMMENT_ORDER_NEWEST_FIRST, and because of bug 40570, those are actually misinterpreted to be "give me the defaults"

Wesley Tanaka’s picture

Here's a potential migration path to a "better fix" after this patch gets committed:

1) drop mode and sort columns from the users table in the database
2) during the upgrade procedure that drops those columns, re-save the mode and sort information in the "data" column, if they weren't set to 0 (to preserve the behavior from bug 40570
3) fix bug 40570 by changing the test to isset($user->mode) and isset($user->sort) (which would properly distinguish "unset" from the number 0)

Or:

1) allow both mode and sort columns to take NULL
2) update all mode and sort columns with value 0 to NULL during the upgrade
3) test for $user->mode === NULL or $user=>sort === NULL (or unset, I'm not sure how user_load works in this case)

Wesley Tanaka’s picture

verified that patch still applies against 4.7.0-test2

Wesley Tanaka’s picture

aha. found it. I think this is a duplicate of http://drupal.org/node/40761, which has a better way of dealing with the problem.

Wesley Tanaka’s picture

Status: Needs review » Closed (duplicate)