Download & Extend

Taxonomy not diffed correctly

Project:Diff
Version:5.x-2.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

I'm seeing some problem with nodes that have several taxonomy terms from several vocabularies. It looks like the $old_taxonomy and $new_taxonomy arrays aren't being built the same way, somehow. For instance, the new array will have two empty terms instead of the terms as in the old array.

So, the attached patch adds the tids as keys for the arrays. It fixes the problem and as an added bonus, it'll also show diffs when the terms are different, but the names are the same.

AttachmentSize
contrib-5.diff.taxonomy.junyor.patch1.8 KB

Comments

#1

Whoops! I left some debug code in.

AttachmentSize
contrib-5.diff.taxonomy.junyor.patch 1.63 KB

#2

Status:needs review» needs work

No, that didn't fix it.

#3

Status:needs work» needs review

There seems to be two problems:

* Single-select vocabularies aren't handled correctly. When this problem is encountered, blank lines appear in the "new" diff
* Taxonomy terms aren't ordered in any coherent way, so something can show up in the diff that shouldn't just because it's ordered differently in the old taxonomy vs. the new taxonomy

The former issue is a pretty straight-forward fix, but the latter isn't. I've attached a patch for the former issue.

I tried to fix the latter issue by using tids as keys for the result arrays, but the diff didn't seem to like it when the array keys weren't contiguous. Any suggestions for fixing that?

Setting to needs review for the first issue.

AttachmentSize
contrib-5.diff.taxonomy2.junyor.patch 1.91 KB

#4

If D6 is broken, we should fix it first if possible.

#5

Status:needs review» needs work

anyone available to port this to D6? D7 (we want to submit this to core)

#6

subscribe

#7

Taxonomy revision diffs don't work at all. This is because the taxonomy module only associates node_terms with NID and not NID+VID (VID is the revision number). Theirfor when it loads the term data for $new_node and $old_node it's the same...and therefor you can't not get diff data from it.

I believe the taxonomy module would have to get changed to resolve this or glue would have to be added with another module.

Function in question. taxonomy.module

function taxonomy_node_get_terms($nid, $key = 'tid')

#8

I've been exploring this a bit more and I'm running into some problems with mulit-select or freetagging vocabularies. The diffing is done based on array keys, but I can't find a good key for these vocabularies. Any ideas?

@j0rd: $new_node and $old_node have arrays of taxonomy terms with all the needed information.

#9

@j0rd: Sorry, I see what you mean now. Yes, there's no way to diff existing revisions. It is still possible to diff an existing node with an edit, though.

#10

Here's a new patch that resolves all the issues I've found except the problem diffing existing revisions. Now the diff is built using vocab name and term name to guarantee uniqueness and aid in sorting.

AttachmentSize
contrib-5.diff.taxonomy3.junyor.patch 3.61 KB

#11

@Junyor -any chance you want to maintain this module? I have pretty much moved on. I gave you CVS access so you can at least commit his patch.

#12

@moshe: I appreciate the offer, but unfortunately I won't be able to do so due to other obligations.

#13

Based on @Junyor's D5 work, I've had a go at a patch for D6, which is attached.

AttachmentSize
taxonomy.inc_.patch 3.37 KB

#14

Nuts, minor syntax update. Apologies.

AttachmentSize
taxonomy.inc2_.patch 3.37 KB