Taxonomy not diffed correctly

Junyor - March 21, 2008 - 21:46
Project:Diff
Version:5.x-2.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

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

#1

Junyor - March 21, 2008 - 21:47

Whoops! I left some debug code in.

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

#2

Junyor - March 21, 2008 - 22:05
Status:needs review» needs work

No, that didn't fix it.

#3

Junyor - March 21, 2008 - 23:25
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

moshe weitzman - March 22, 2008 - 13:59

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

#5

moshe weitzman - May 22, 2008 - 19:11
Status:needs review» needs work

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

#6

george@dynapres.nl - May 29, 2008 - 09:54

subscribe

#7

j0rd - December 11, 2008 - 14:38

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

Junyor - March 30, 2009 - 23:37

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

Junyor - March 31, 2009 - 16:26

@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

Junyor - March 31, 2009 - 17:46

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

moshe weitzman - March 31, 2009 - 21:25

@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

Junyor - March 31, 2009 - 21:30

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

 
 

Drupal is a registered trademark of Dries Buytaert.