The validation in #2483841 seems to cause issues when the user entity has a field attached to it.
There's a warning first:
Warning: array_merge(): Argument #1 is not an array in field_default_extract_form_values() (line 36 of /home/vagrant/sites-defaults/bcss/drupal/modules/field/field.default.inc).
Then the fatal error:
Recoverable fatal error: Argument 2 passed to drupal_array_get_nested_value() must be of the type array, null given, called in /home/vagrant/sites-defaults/bcss/drupal/modules/field/field.default.inc on line 38 and defined in drupal_array_get_nested_value() (line 6771 of /home/vagrant/sites-defaults/bcss/drupal/includes/common.inc).
These happen because $form in field_default_extract_form_values() is the form id "user_register_form", when it's expecting the full form array.
I've traced this back to the new call to user_register_validate() in _user_resource_create(), where the form ID is passed, but as we don't have the full form array at that point I'm a bit stumped on what to do next to fix this.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | newuservalidationfails-2543010-9.patch | 834 bytes | mario_prkos |
| #6 | validationofuserfail-2543010-6.patch | 657 bytes | DrupalChimp |
Comments
Comment #1
kylebrowning commentedShit.
Comment #2
rakesh.nimje84@gmail.com commentedI am also facing the same issue. Any solution ?
Comment #3
light9 commentedthis headashe stopped my job
Comment #4
xanfar commentedI am using services version 7.x-3.13
I found the user_register_validate() function mentioned in the original post on line 339 of user_resource.inc
I was having this same problem also and found that if i got the form array first
$formForCheck = drupal_get_form('user_register_form');then validated with that value. Validation seems to still work during my service calls
user_register_validate($formForCheck, $form_state);Comment #5
DrupalChimp commentedSame issue.
Xanfar, suggestion definitely stops the error and creates the user but all the form field values are lost during drupal_process_form() in form.inc. as documented here https://www.drupal.org/node/1699288
Although I've just realised that's an old bug.
Comment #6
DrupalChimp commentedOk, not taking credit for this. That's all xanfar. But here is a patch.
Comment #7
xanfar commentedThank You DrupalChimp.. so in our case since $form_state['values'] is being defined by the $account variable.
Should I be adding the line:
$form_check = drupal_get_form('user_register_form');above any $form_state modifications (line 308).
When drupal_get_form() defines $form_state as an empty array... will this make a difference?
Comment #8
DrupalChimp commentedComment #9
mario_prkos commentedI can confirm that problem. I am using 7.13 version of module. Drupal version is 7.41.
Even if I put the patch values are not composed in function field_default_extract_form_values in field.default.inc which gives error Fatal error: Cannot unset string offsets in ...modules/field/field.default.inc on line 41. If I simple remove user_register_validation it works and validation is still perform. I tested with some garbage in data and use service to create user.
From documentation in code about drupal_form_submit function is visible that this function populates errors that are retrievable with form_get_errors. So it looks that this function performs validation. Test also confirms that.
I am not sure is this validation in function user_register_validate($formForCheck, $form_state) is really needed but anyway I would like to see other peoples opinions.
Comment #10
aron novak@mario_prkos I can confirm what you say. resources/node_resource.inc does not do anything like that and indeed drupal_form_submit does validation, as we just check it later. And hard-coding a single validation callback is quite problematic. What if someone alters it for a good reason via Form API? I think we can safely get rid of couple of lines here and let drupal_form_submit does the validation, without any kind of performance optimization that decreases the flexibility.
Comment #11
mario_prkos commentedThanks Aron for insight. Here is the patch.
Comment #12
xanfar commentedI have to agree with Mario and Aron. #11 seems to be a working solution for me and I can confirm that validation still occurs. Thank you
Comment #13
kylebrowning commentedComment #15
kylebrowning commented