The code in the contact module shows a difference in behaviour between users who haven't saved their personal contact form preference when the setting for 'Enable the personal contact form by default for new users.' is set to "true".
Users created before the module was enabled will have their contact forms disabled, even when they didn't make a selection. Users created after the module was enabled will have their contact forms enabled, also when they didn't make a selection yet.
The current behaviour is very annoying when the module is first enabled on a site with a large number of existing users. There is no easy way to go in and enable the form for all users aside from writing a custom PHP script. It makes more sense to use the default value when the user hasn't explicitly made a choice. The attached patch does that.
Comment | File | Size | Author |
---|---|---|---|
#36 | 1191464-36-test-only.patch | 1.17 KB | lokapujya |
#36 | interdiff-1191464-36.txt | 871 bytes | lokapujya |
Comments
Comment #1
Peter Bex CreditAttribution: Peter Bex commentedThis also applies to Drupal 6, but I don't know how to make this bugreport apply to multiple versions. Here's the same patch for D6, in any case.
Comment #2
Peter Bex CreditAttribution: Peter Bex commentedCome to think of it, possibly the insert hook should be removed altogether. This would allow the administrator to change default behaviour for all users, except those who have explicitly made a selection in their profile.
Comment #3
pfrenssenThis can indeed be an annoying issue but I disagree with #2. Currently it errs on the side of caution, which is usually the sane way to do it. I can think of cases where it would be acceptable to enable this by default for new users but unacceptable to force this onto the existing user base without asking permission.
A good solution would perhaps be to add another option to the settings:
Comment #4
pfrenssenHere is a patch that implements the proposal in #3.
Comment #5
Everett Zufelt CreditAttribution: Everett Zufelt commentedAll issues are resolved against 8.x, and then are considered for backport to earlier versions.
I agree that contact forms should not be enabled by default for existing users, in fact, to do so, is an expensive task. It currently requires a user_load and user_save for each user in order to enable the contact form for existing users, it may also conflict with privacy settings that have been established on the site.
It is a relatively simple task to write a module to enable the contact form for all existing users if a site builder requires this.
Comment #6
thedavidmeister CreditAttribution: thedavidmeister commentedpatch no longer applies.
@Everett Zufelt - there is no user_load() and user_save() in the patch in #4 and no conflict with existing privacy settings, it appears to simply extend the logic at the point the contact form is deciding whether to display itself to check if the user's preference is empty and if the site admin has elected to display the form for existing users with no preference.
Comment #7
pfrenssenUpdating tags.
Comment #8
reszliComment #9
Alumei CreditAttribution: Alumei commentedIf I'm not mistaken the patch from #4 was made against 7.x.
I'm afraid it can't be re-rolled against 8.x.
If it's still an issue in 8.x maybe you should start from scratch rather that re-rolling.
Comment #10
andypostThis is a bug, and really needs re-roll or new patch
All users that never saved contact setting (profile form) should inherit default setting
Comment #11
rpayanmPlease review.
Comment #13
andypostnice idea, missing schema for new config and integration test
Comment #14
lokapujyaThe comment preceding the condition should be updated to explain the additional contact settings check.
Comment #15
lokapujyaAdding missing schema.
Comment #17
Studiographene CreditAttribution: Studiographene commentedThis is a updated Patche
Comment #18
lokapujyawhat changes did you make? It seems like unintended changes got added because the patch is really big. If something was changed, you should include an interdiff that shows the changes.
Comment #19
lokapujyaNoticed that the standard profile includes contact installed by default now in 8. Does anyone know if that is intentional?
Comment #20
madhavvyas CreditAttribution: madhavvyas as a volunteer commentedThe comma at the end of the last array element
Comment #21
rajeevkCreated patch from #15 & added suggested comma !!
Patch in #17 doesn't seem to be in sync.
Comment #24
lokapujyaAdded code to the submit handler to save the new form value.
Comment #26
lokapujyaOops, adding back schema.
Added the start for a new test.
Comment #30
lokapujyaUpdated the test.
Comment #33
lokapujyaThis might not be a bug in D8. Let's check.
Comment #36
lokapujyaMinus the default scope.
Since this test passes, then the bug isn't in D8. We might want to add the test? Then, it can be moved back to a D7 bug.
Comment #39
andypostYep looks it works but extended test coverage needed for 8.x
Comment #40
crashtest_ CreditAttribution: crashtest_ as a volunteer commentedIf I am reading this correctly, the behavior should be that if I enable the setting after users have been created, and they had no preference set (which I don't see a way in 8 to set a pref per user) then their forms should also be enabled.
So, I personally am seeing two problems, number 1, the above doesn't happen for me, and number 2, there is no setting per user that I can see.
Comment #41
crashtest_ CreditAttribution: crashtest_ as a volunteer commentedIn my case the form field display for Contact Settings at admin/config/people/accounts/form-display was hidden when I enabled the site-wide setting for turning on personal contact forms. Just FYI.
Comment #42
lokapujyaConfused. Is the test added by this patch sufficient?
Comment #43
andypostI think we can try same test for d7 and it should fail, if not then test is wrong
Comment #45
jibranNW as per #43.