The code in taxonomy_term_save does not check to see if the parent variable is not null before it tries to insert data into taxonomy_term_hierarchy. We should check that the parent tid is not null first.

This bug is difficult to reproduce. It occurs SOMETIMES when saving a taxonomy term using the taxonomy_manager module. I chose a taxonomy term on the root level and clicked save. The following error appears. After closing the pop up, the term no longer appears in the taxonomy manager because its taxonomy_term_hierarchy record was deleted.

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /system/ajax
StatusText: Service unavailable (with message)
ResponseText: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'parent' cannot be null: INSERT INTO {taxonomy_term_hierarchy} (tid, parent) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array
(
[:db_insert_placeholder_0] => 15152
[:db_insert_placeholder_1] =>
)
in taxonomy_term_save() (line 679 of .../modules/taxonomy/taxonomy.module)

CommentFileSizeAuthor
#11 core-2064395-prevent_null_parent_tids.patch1.34 KBAnonymous (not verified)
#9 core-2064395-prevent_null_parent_tids.patch1.34 KBAnonymous (not verified)
#6 core-2064395-prevent_null_parent_tids.patch1.37 KBAnonymous (not verified)
#4 core-2064395-prevent_null_parent_tids.patch1.41 KBAnonymous (not verified)
#3 2064395-prevent_null_parent_tids.patch904 bytesAnonymous (not verified)
#1 2064395-prevent_null_parent_tids.patch904 bytesAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Status: Needs work » Needs review
FileSize
904 bytes

Status: Needs review » Needs work

The last submitted patch, 2064395-prevent_null_parent_tids.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
904 bytes
Anonymous’s picture

Updated patch

Status: Needs review » Needs work

The last submitted patch, core-2064395-prevent_null_parent_tids.patch, failed testing.

Anonymous’s picture

Updated patch

Anonymous’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, core-2064395-prevent_null_parent_tids.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
1.34 KB

Status: Needs review » Needs work

The last submitted patch, core-2064395-prevent_null_parent_tids.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
1.34 KB
Anonymous’s picture

Bump. Can I get some eyes on this please?

Anonymous’s picture

Bump. Can I get some eyes on this please?

kdborg@gmail.com’s picture

Issue summary: View changes

I had this issue with a migration using a default value of 0 for terms that didn't have a parent. It appears to work for that case.

iaminawe’s picture

I am not sure why but this bug recently started happening to me with addressfield when trying to save a profile and this patch was the only thing that worked to remove the error and allow profiles to be saved. +1 for this being committed - works great for me. Thanks