Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When saving a term I get the error user warning: Duplicate entry '17' for key 'PRIMARY' query: INSERT INTO taxonomy_title (tid, title) VALUES (17, '') in /.../taxonomy_title/taxonomy_title.module on line 161.. 17 is the tid of the term.
Comment | File | Size | Author |
---|---|---|---|
#6 | add_check_for_existing_title-1205016-6.patch | 2.85 KB | jenlampton |
#5 | updated_form_check-1355968-2.patch | 1.31 KB | joostpluijmers |
#1 | taxonomy_title-1205016-1.patch | 591 bytes | fuerst |
Comments
Comment #1
fuerst CreditAttribution: fuerst commentedLooks like an empty title will trigger the insert in
_taxonomy_title_update()
. Asdb_result()
returns FALSE if no record found you can use that for triggering the update instead. Attached patch fixes that.BTW: Wouldn't it be better to delete a record from {taxonomy_title} once a title gets empty?
Comment #2
jenlamptoncleaning up queue
Comment #3
fuerst CreditAttribution: fuerst commentedHow did you fix the issue? Did not find a related commit. Therefore resetting status to the former one.
Comment #4
jenlamptonIf you check the dev branch, there are already issets wrapped around the insert and update hooks that solve this problem. If you'd like to add a delete when title is empty though, I'll review that patch :)
Comment #5
joostpluijmers CreditAttribution: joostpluijmers commentedAh yea, those lines are probably the result of my overachieving IDE. The produced was:
user warning: Duplicate entry '2' for key 'PRIMARY' query: INSERT INTO taxonomy_title (tid, title) VALUES (2, '') in taxonomy_title.module on line 161.
This error occurred in the event that you edit a term with an empty title. The empty titles were caused by checking if a $form_state value was set, which it always is due to the form API. The update function checks against existence of a record which exists with an empty title string, but the check fails because an empty string is also false (go PHP freetyping ;). Thus causing the insert error.
I uploaded a new patch, with only the necessary lines. It also includes a ‘no query’ check by submitting an arbitrary flag that signals if there was a previous taxonomy title.
Comment #6
jenlamptonGreat work :)
I've cleaned up some of your syntax: changed true to TRUE and added/removed some spaces where necessary. See http://drupal.org/coding-standards for reference. Here's a new patch. Can you test this one and make sure it works the same as yours?
Comment #7
joostpluijmers CreditAttribution: joostpluijmers commentedThanks for the cleanup, I will have to outfit a formatter to match those coding standards and try out those development modules.
All mutations on terms and titles are working like in my patch. This works.
Comment #8
jenlamptonThanks! (In the future, you can also change the status of the issue when you leave your comment)
Do you feel up to providing a matching patch for the D7 branch? :)
Comment #9
jenlamptoncommitted to 6.x-1.x . will be included in the next release.
Comment #10
joostpluijmers CreditAttribution: joostpluijmers commentedThen I am now officialy a Drupal contributor. :)
*Pops the cork*
Comment #11
jenlamptonCongratulations, and thank you! :)