Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Here's the error that is thrown when trying to add a new user:
Notice: Array to string conversion in form_process_checkbox() (line 1380 of core/includes/form.inc).
To reproduce
- Install the latest HEAD
- Go to admin/people
- Hit the Add user button (admin/people/create)
Comment | File | Size | Author |
---|---|---|---|
#9 | drupal8.contact.2231495-8.patch | 1.3 KB | ACF |
#6 | 2231495-test-6.patch | 542 bytes | ACF |
#2 | 2231495-2.patch | 755 bytes | andrei.dincu |
#1 | add-user-notice.png | 27.38 KB | andrei.dincu |
Comments
Comment #1
andrei.dincu CreditAttribution: andrei.dincu commentedThis is the notice you will receive when a new user is added.
Comment #2
andrei.dincu CreditAttribution: andrei.dincu commentedCheck if $value is an array and transform it to string using implode().
Comment #3
andrei.dincu CreditAttribution: andrei.dincu commentedComment #4
rahulbile CreditAttribution: rahulbile commentedPatch seems to fix the issue properly.
Comment #5
webchickHm. We should be able to add a test that catches this. In fact, I'm mystified how existing tests are not catching this... adding a user from admin/people is not exactly the outer limits.
Comment #6
ACF CreditAttribution: ACF commentedJust investigated why the UserCreateTest wasn't picking up the error, as on the face of it it should have been. It turns out it's because contact module isn't enabled in the test. Have added a patch which will pick up the error, not sure this is a change that needs to be committed.
Comment #7
ACF CreditAttribution: ACF commentedTo show test failing.
Comment #9
ACF CreditAttribution: ACF commentedWorked out that the problem is being caused by contact_form_user_form_alter. The account_data default for the contact form is set as an array if their is no account id for the form (i.e. when there is an empty form). UserData->get returns the array which I assume is correct so I made a fix in the form_alter function.
I've left the 'contact' enabled in the usercreate simpletest to pick up the error. Wonder whether should write a new test for the contact module which checks that field, any thoughts?
Comment #10
filijonka CreditAttribution: filijonka commentedhi
checked this one and if the change to the test is added without patch the test fails which is what we want.
When adding the patch it works as it is supposed to do and test passes.
Comment #11
filijonka CreditAttribution: filijonka commentedI'm feeling lucky..I'm setting this to done..it does the job as far as I'm concerned..can't see any trouble with it
Comment #12
alexpottCommitted 562adda and pushed to 8.x. Thanks!
Comment #14
marcingy CreditAttribution: marcingy commentedThis is a duplicate of #2030743: Improve tests for user form alters in contact module which has more far reaching tests :(
Comment #15
anavarreComment #17
YesCT CreditAttribution: YesCT commented#2030743: Improve tests for user form alters in contact module is going to undo this and add actual test coverage as webchick asked for.