Field types are free to name their 'columns' the way they like, but conventionally, reference fields use a column name that indicates what's in the field:
noderef field's column is 'nid', userref is 'uid', fielfield is 'fid'... similarly, taxo field should be 'tid'.

Comments

c960657’s picture

Status: Active » Needs review
StatusFileSize
new8.01 KB

This removes all 'value' occurrences in taxonomy.module.

I'm not sure about the change to taxonomy_field_widget_error(). I don't understand when $element['tid'] or $element['value'] is set?

Status: Needs review » Needs work

The last submitted patch failed testing.

yched’s picture

Thanks for tackling this, c960657.
Forum heavily uses taxonomy, and should be updated accordingly
forum_node_prepare(), forum_node_validate(), forum_node_presave()...
Beware that we don't want to change stuff like 'title' => $object->title[FIELD_LANGUAGE_NONE][0]['value'],, of course.

It's very possible that some taxonomy or forum tests need to be updated to reflect the change.

About taxonomy_field_widget_error(): Mmh, actually that function should simply be

function taxonomy_field_widget_error($element, $error) {
  form_error($element, $error['message']);
}

because taxonomy.module implements only one widget itself - so that other code branch is never executed.

c960657’s picture

Status: Needs work » Needs review
StatusFileSize
new15.39 KB

This addresses the comments in #3.

The taxonomy tests were broken. field_attach_validate() just assumed that no tid was specified and did not throw an exception, but the test did not properly detect this (adding an assertTrue() to the catch block doesn't help, if nothing is caught).

yched’s picture

Status: Needs review » Needs work

Good call on the variable renames in a few foreach() loops.

About the taxo test: I think the pattern used elsewhere to test whether an exception happens or not is:

try {
  bla();
  $this->pass(t('bla() did not raise an exception.'));
}
catch (Exeption $e) {
  $this->fail(t('bla() did not raise an exception.'));
}
<code>
or 
<code>
try {
  bla();
  $this->fail(t('bla() raised an exception.'));
}
catch (Exeption $e) {
  $this->pass(t('bla() raised an exception.'));
}

+ the scope of $e is limited to the catch (Exeption $e) { ... } block, so no need to reset $e between two try / catch sequences.

Other than that, looks ready to me.

c960657’s picture

StatusFileSize
new15.4 KB

Done (I assume your comment about $e was related to the previous implementation).

yched’s picture

Status: Needs work » Reviewed & tested by the community

Cool ! RTBC.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks!

yched’s picture

Title: Taxonomy field 'column' should be 'tid' instead of 'value' » [HEAD BROKEN] Taxonomy field 'column' should be 'tid' instead of 'value'
Priority: Normal » Critical
Status: Fixed » Reviewed & tested by the community

The forum.module hunks were left out of the commit, forum tests fail on HEAD.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Fixed. Committed.

yched’s picture

Title: [HEAD BROKEN] Taxonomy field 'column' should be 'tid' instead of 'value' » Taxonomy field 'column' should be 'tid' instead of 'value'
Priority: Critical » Normal

Thx Dries. Resetting title and priority for posterity.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.