I get the following error: One of my sites, user edit its comment, and the comment post date was the user's register date. I spent lot's of time to investigate, and I've found, the global $user, and all of the $user array by user_load() had tons of unnecessary data.
When in user/%/edit page hit the submit button, the user_save() get all of $form_state['value'] included the complete $node object.
I haven't better idea: I cleaned the $form_state['values'] before user_save(), then undo before node_form_submit() starts:
// prevent to store all values in user->data field, and give it back, before node_form_submit
$cache = $form_state['values'];
foreach ($account as $key => $value) {
if (isset($value)) {
$account_keys[] = $key;
}
}
foreach ($form_state['values'] as $key => $value) {
if (!in_array($key, $account_keys)) {
unset ($form_state['values'][$key]);
}
}
user_save($account, $form_state['values'], $category);
$form_state['values'] = $cache;
Are there any possible better solution?
Comments
Comment #1
szantog commentedThe previous patch works - until turning on a new module, that alter to the user_form too. The altered new data isn't saved, because it isn't in $account array. In patch there are a _multi_array_key_exist helper function, but i don't want to comy here.
Comment #2
cpliakas commentedApplied the patch, and it seems to work as expected. No more node dump in the data column! Thanks for your work on this issue, szantog.
~Chris
Comment #3
kenorb commentedThanks for the work.
Committed:
http://drupalcode.org/project/account_profile.git/commit/5c9d657