Currently, taxnomy_node_get_terms() only respects the given key the first time it is called for a specific node. The second time, no matter what key is given, it will use the same key. This is because the static variable in which it is cached, is only cached by nid, and not by the key.

Patch is attached. It has a simple and clean solution IMO.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Version: 5.1 » 6.x-dev
Status: Needs review » Reviewed & tested by the community

Nice catch but we usually fix HEAD first and port down.

Wim Leers’s picture

Title: Bug in taxonomy_node_get_terms: the index key is not always respected » Bug in taxonomy_node_get_terms(): the index key is not always respected
FileSize
1.06 KB

In my excitement of finding my very first Drupal Core bug, I forgot to check HEAD first :P But since it's so trivial, here's the patch for HEAD already. Now you can commit both :)

Wim Leers’s picture

Oops! My superhandy new patch-generating tool did not take the paths into account.

Fixed patch for HEAD attached, 5.1 will follow.

Wim Leers’s picture

And the updated patch for 5.1.

Dries’s picture

Version: 6.x-dev » 5.x-dev

Good catch. Committed to CVS HEAD, but needs to be backported to DRUPAL-5.

(Might be worth it to inspect the other taxonomy_ functions for similar mistakes.)

Wim Leers’s picture

Sorry for the confusion, but my "5.1 patch" is actually a DRUPAL-5 patch :) So it's there already, in #4.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 5.

Anonymous’s picture

Status: Fixed » Closed (fixed)