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.

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
StatusFileSize
new1.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

StatusFileSize
new1.08 KB

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

StatusFileSize
new1.04 KB

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)