When saving a float field with an empty value I get an ajax error 500.
Fresh install using the latest dev version of editable fields and Drupal 7.42.
Cheers,
Dan
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 2668060-18.patch | 2.54 KB | joelpittet |
| #15 | ajaxerror500onsavenull-2668060-15.patch | 1.35 KB | cheval |
| #10 | ajaxerror500onsavenull-2668060-10.patch | 1.23 KB | cheval |
| #3 | ajaxerror500onsavenull-2668060-2.patch | 1.2 KB | cheval |
Comments
Comment #2
cheval commentedI have the same issue with a Term reference field. The terms are listed in checkboxes, when I uncheck all boxes and hit 'Save', I get the following error with an empty response (in dutch):
The log report gives the following error:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'tid' cannot be null: INSERT INTO {taxonomy_index} (nid, tid, sticky, created) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 104 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => 1474364730 ) in taxonomy_build_node_index() (regel 1981 van modules/taxonomy/taxonomy.module).Comment #3
cheval commentedPatch included
When an empty field is submitted, the field value in the $entity object is set to NULL, which results a db error
The patch loops the $entity object fields for NULL values and modifies the object so the $entity can be saved correctly.
Comment #4
cheval commentedComment #5
Frederic wbase commentedpatch in #3 works like a charm!
Comment #6
murphy1484 commented#3 seems to be working
Comment #7
Frederic wbase commentedChanged status to RTBC, can we get this into dev or stable release?
Comment #8
Frederic wbase commentedComment #9
joelpittetThis may solve the problem but we shouldn't be hardcoding languages into the module this with 'UND'. Not sure the best way to handle this but maybe use entity_metadata_wrapper() and then you don't have to deal with the language.
Comment #10
cheval commentedRight, instead of the 'und' string the constant 'LANGUAGE_NONE' should be used. This has been updated.
Comment #11
cheval commentedComment #12
Frederic wbase commentedComment #13
joelpittetConsidering we are requiring Entity API, there is a helper to ensure that we are getting the right language. Typically it's on
$entity->languageotherwise default toLANGUAGE_NONE.entity_metadata_field_get_language($entity_type, $entity, $field)I'm a bit unsure the steps to reproduce this bug as you can create a schema that would allow NULL values and I've not seen this pattern to resolve this elsewhere in Drupal yet. So I'm setting this "Needs work" to provide steps to reproduce.
@Frederic wbase, please provide some sense that you tested this in your comment when switching the status to RTBC.
Comment #14
dansanjou commentedThanks @cheval, the patch is working perfectly!
Comment #15
cheval commentedNULL values are not allowed by default if I'm not mistaken, what more information would you need to reproduce the steps? My issue appeared on the 'View' page of a node where I was saving a checkbox list that was completely unchecked.
I updated the patch where I ended up using the
field_languagefunctionComment #16
cheval commentedSteps to reproduce:
Comment #17
joelpittetThanks @cheval, the steps were helpful, except for "Select list" because you actually want "Check boxes/radio buttons" for the save button to show on the node display. May want to edit your comment above.
Comment #18
joelpittetHere's a patch that fixes it and removes some of the kludge built up of the years. The validation is done through the _validate() step and calling it again messes with the values.
I tested it with views and without views and with and without validation and it works fine. Also tested the cache issues.
Give that patch a try.
Comment #19
joelpittet@cheval when you have a chancel let me know if this will suffice because I'd really like to commit this.
Comment #20
cheval commentedThanks for the update Joel, I'll test the patch as soon as I can.
Thanks for pointing out the error in my previous post, it's been edited :)
Comment #21
cheval commentedYour patch seems to be working, tested on a clean Drupal 7.54 installation.
I've tested both issues in this thread, saving an empty float field and saving a term reference checkbox list, both with success.
Comment #23
joelpittetThanks for testing it too, that cleans it up and leaves the validation in the separate validate callback function!
I've committed this to dev.