hook_taxonomy_term_insert() and hook_taxonomy_term_update() are backwards. Here is a simple patch to fix them but we should also create a test to make sure this doesn't happen in the future.

Comments

dries’s picture

Status: Active » Fixed

The test bot hasn't run yet, but this looks like an obvious fix. Committed.

damien tournoud’s picture

Status: Fixed » Active
Issue tags: +Needs tests

Let's write some tests for that.

dropcube’s picture

Status: Active » Needs review
StatusFileSize
new7.01 KB

Tests for taxonomy terms hooks are there, but the way taxonomy_test.module implement those hooks, doesn't cover bugs like this one.

The attached patch update the taxonomy_test.module, to fix the implementations of taxonomy terms hooks and simplify them.

Instead of having one-to-many relationship of term-antonyms, is simplest to have one-to-one relationship, it's just a test module.

catch’s picture

A few tabs crept into the patch:

-  }
+function taxonomy_test_get_antonym($tid) {
+	return db_select('taxonomy_term_antonym', 'ta')
+	    ->fields('ta', array('name'))
+	    ->condition('tid', $tid)
+	    ->execute()
+	  ->fetchField();
 }
dropcube’s picture

StatusFileSize
new7.02 KB

Fixed.

catch’s picture

still some tabs here, and the fetchField() should be indented the same as the other chained methods. Otherwise looks RTBC.

+function taxonomy_test_get_antonym($tid) {
+  return db_select('taxonomy_term_antonym', 'ta')
+      ->fields('ta', array('name'))
+      ->condition('tid', $tid)
+      ->execute()
+    ->fetchField();
 }
dropcube’s picture

StatusFileSize
new7.02 KB
catch’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Excellent! Committed to HEAD.

tylor’s picture

This is great, thanks dropcube! Wishing I could have helped with writing but wasn't sure where to start ;)

Status: Fixed » Closed (fixed)
Issue tags: -Needs tests

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