Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#14 | taxonomy.inc2_.patch | 3.37 KB | joe-b |
#13 | taxonomy.inc_.patch | 3.37 KB | joe-b |
#10 | contrib-5.diff.taxonomy3.junyor.patch | 3.61 KB | Junyor |
#3 | contrib-5.diff.taxonomy2.junyor.patch | 1.91 KB | Junyor |
#1 | contrib-5.diff.taxonomy.junyor.patch | 1.63 KB | Junyor |
Comments
Comment #1
Junyor CreditAttribution: Junyor commentedWhoops! I left some debug code in.
Comment #2
Junyor CreditAttribution: Junyor commentedNo, that didn't fix it.
Comment #3
Junyor CreditAttribution: Junyor commentedThere 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.
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedIf D6 is broken, we should fix it first if possible.
Comment #5
moshe weitzman CreditAttribution: moshe weitzman commentedanyone available to port this to D6? D7 (we want to submit this to core)
Comment #6
mo6subscribe
Comment #7
j0rd CreditAttribution: j0rd commentedTaxonomy 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')
Comment #8
Junyor CreditAttribution: Junyor commentedI'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.
Comment #9
Junyor CreditAttribution: Junyor commented@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.
Comment #10
Junyor CreditAttribution: Junyor commentedHere'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.
Comment #11
moshe weitzman CreditAttribution: moshe weitzman commented@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.
Comment #12
Junyor CreditAttribution: Junyor commented@moshe: I appreciate the offer, but unfortunately I won't be able to do so due to other obligations.
Comment #13
joe-b CreditAttribution: joe-b commentedBased on @Junyor's D5 work, I've had a go at a patch for D6, which is attached.
Comment #14
joe-b CreditAttribution: joe-b commentedNuts, minor syntax update. Apologies.
Comment #15
mitchell CreditAttribution: mitchell commentedRe #13.
Comment #16
mitchell CreditAttribution: mitchell commentedActually, #13 also answers #5.
Comment #17
Alan D. CreditAttribution: Alan D. commentedClosed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.