There is a problem with storing serialize data in the $user->data field. To recreate
* Do a minimal install
* Enable the contact module
* Go to user/1/edit
* Click save - the first time the data is save correctly in the user->data field
* Then when the page is reloaded user->data is returned to during user load in an serialised format
* Click save again the data in user->data is reserialized and saved and looks like this s:24:"0:1:{s:7:"contact";i:0;}";
* When user edit reloads an error is generated in drupal_unpack
Warning: Invalid argument supplied for foreach() in drupal_unpack() (line 1179 of C:\code\drupal\includes\bootstrap.inc).
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | be_gentle_to_this_old_old_cycle.patch | 720 bytes | chx |
| #1 | drupal_unpack.patch | 415 bytes | marcingy |
Comments
Comment #1
marcingy commentedPatch to amend unpack so as the data that was unorginally serialized is unserialized and can be subsquentally saved without generating unpack errors when it is reserialised.
Comment #2
marcingy commentedComment #3
marcingy commentedAfter speaking to chx this approach is totally wrong but as it stands enabling the contact module is going to produce drupal_unpack errors after the first save.
Comment #4
chx commentedChanging a function like that this late? That's a recipe for catastrophe. What about this, however?
Comment #5
chx commentedIt broke http://drupalcode.org/viewvc/drupal/drupal/modules/user/user.module?r1=1... here.
Comment #6
marcingy commentedMuch nicer than my solution. Tested locally if the bot goes green this can be set to RBTC.
Comment #7
marcingy commentedComment #8
catchLooks good if the testbot comes back green, I got fails before doing it this way 'round, but some other fixes have gone in since then so we might be alright by now.
Comment #10
catchThe issue is at the moment $account->data can sometimes be an array, sometimes unserialized.
Either we add a tonne of cruft in user_save() to check for all the possibilities, or we could see how marcingy's approach works. Let's at least see what happens with the test bot on that patch, since to me having that data as an actual array seems like the right fix here and no explanation has been given why it's such a bad idea.
Additionally this is a duplicate of #721436: Remove magical fairy saving of cruft from user_save() which is still open for cleanups.