Vocabulary edit form resets the 'hierarchy' field to '0' and 'relations' field to '1'

David Lesieur - January 3, 2009 - 06:41
Project:Drupal
Version:7.x-dev
Component:taxonomy.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

The vocabulary edit form hardcodes the value of the 'hierarchy' flag to '0', therefore resetting it when the form is submitted and the vocabulary saved.

This flag is normally assigned though taxonomy_check_vocabulary_hierarchy() which is called when terms are modified.
I think it should be '0' when first creating a vocabulary, but preserved whenever an existing vocabulary is edited—which is what this tiny patch does.

AttachmentSizeStatusTest resultOperations
taxonomy-hierarchy.patch932 bytesIdleFailed: Failed to apply patch.View details | Re-test

#1

David Lesieur - March 3, 2009 - 06:12

I'm surprised that no one seems to have stumbled onto this bug.

The patch still applies...

#2

Mark Theunissen - March 3, 2009 - 16:32

Yep, I had noticed this before but thought nothing of it, until I installed Faceted Search and ran into the bug. Patch applies and solves the issue. Thanks David!

#3

domidc - April 10, 2009 - 12:57

I confirm that the patch works. Also ran into it using faceted search.

#4

David Lesieur - April 14, 2009 - 20:10

To others who might wonder: This is really a (trivial) bug in Drupal core. Faceted Search only springs up because only a few modules rely on this flag.

#5

David Lesieur - April 28, 2009 - 15:22
Version:6.x-dev» 7.x-dev

Re-rolled patch for D7.

AttachmentSizeStatusTest resultOperations
taxonomy-hierarchy-d7.patch932 bytesIdlePassed: 11345 passes, 0 fails, 0 exceptionsView details | Re-test

#6

Arancaytar - April 28, 2009 - 15:49
Title:Vocabulary edit form resets the 'hierarchy' field to '0'» Vocabulary edit form resets the 'hierarchy' field to '0' and 'relations' field to '1'
Status:needs review» needs work

Neat, but could we fix the similarly hard-coded value of $form['relations'] just below it as well?

There's another slight WTF there: The defaults added to the $edit array at the top of the function make $edit['relations'] default to 0 - but the hard-coded form value forces it to 1. If we continue to enable relations by default, then this value should be changed in the defaults array.

#7

David Lesieur - April 28, 2009 - 16:13
Status:needs work» needs review

Implemented the suggested fixes.

AttachmentSizeStatusTest resultOperations
taxonomy-hierarchy-d7.patch1.3 KBIdlePassed: 11364 passes, 0 fails, 0 exceptionsView details | Re-test

#8

Arancaytar - May 22, 2009 - 08:37
Status:needs review» reviewed & tested by the community

Looks good now.

#9

Dries - May 24, 2009 - 18:02
Status:reviewed & tested by the community» needs work

Can we write a test for this please, or adjust the existing tests? Thanks!

#10

stevenghines - May 29, 2009 - 23:13

Are there any plans to release this patch in the next 6.x version of Drupal? I too am using the faceted search module and found this issue via #420354: Subcategories / Terms not heirachical in Guided Search

#11

netdream - December 4, 2009 - 14:18

yes, please... include it also in D6...
It's really a big issue to have to go back to database each time someone updates the hierarchy parameters...

 
 

Drupal is a registered trademark of Dries Buytaert.