Download & Extend

Taxonomy terms can duplicate on same node

Project:Devel
Version:7.x-1.x-dev
Component:devel_generate
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

This patch allows taxonomy terms (as fields) to be automatically added via Devel Generate.

It has a couple TODOs mentioned in the code, but seems to work fine otherwise. Without this patch, I wasn't able to correctly create forum topics using Devel Generate, but with it I can.

With forums, it also has the interesting property that it often assigns a generated forum topic to more than one forum (which Drupal treats as the topic having been "moved" from one forum to another). Not an actual bug, just interesting - we could perhaps find a way to remove that behavior if we really wanted to.

AttachmentSizeStatusTest resultOperations
devel-taxonomy.patch1.71 KBIdleFAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal/drupal].View details | Re-test

Comments

#1

Status:needs review» active

I committed this, and removed the checkbox on the add content form since terms are now added to new nodes unconditionally.

Note that I am seeing errors like below when creating Article nodes. Note that those have a Tags vocab by default. Help wanted.

Notice: Trying to get property of non-object in taxonomy_implode_tags() (line 944 of /Users/mw/htd/prfr/modules/taxonomy/taxonomy.module).

#2

Status:active» needs review

If the tags term list is empty, then a invalid entry of tid = 0 is assigned to the node in the taxonomy_index table.

I tried just removing $object_field['tid'] = 0; from _taxonomy_cck_generate(), but that just resulted in taxonomy_field_insert() looking for a 'tid' key, a array of multiple empty arrays was being passed.

The attached patch gets the article node creation working again, with and without tags. It needs some more testing against the other fields that support multiple values.

AttachmentSizeStatusTest resultOperations
660758.patch918 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal/drupal].View details | Re-test

#3

Title:Taxonomy terms and forum topics cannot be created» Taxonomy terms can duplicate on same node
Status:needs review» active

This seems to be working fine right now. The only buglet I noticed is that the same term can be added multiple times to same node. Was using a free tag vocab when i saw this. Arguably, this should be solved in core. Does field api have a notion of uniqueness within a multiple value field?

#4

subscribe

#5

Marked #1215326: Generated nodes taxonomy field contains duplicate terms as a duplicate of this.

If core does not prohibit duplicate tags, then users can enter duplicate tags, right? We may not like it when they do that, but if users can misbehave, then why should devel_generate not misbehave occasionally, too?

This is WF imo, or even WAD.

#6

Whilst I agree the core code accepts duplicates, the input types the user is presented with don't. Try adding the same term twice with any of the field widgets. If core properly accepted the same term twice then saving the node form would not remove the duplicates, but it does.

#7

Ok, so what needs fixing, #2 or #3? And what does the patch in #2 try to fix?

Can we get a patch that passes?

#8

subscribe

#9

#1063326: Duplicates of term fields a question in the core queue wether this is a bug or a feature.

#10

The above issue was closed as a duplicate of this one #1050466: The taxonomy index should be maintained in a node hook, not a field hook

On one hand it is awesome to make devel_generate create exactly what core allows, multiples of the same term on a node if that's a possible data point. On the other hand, in terms of modelling real content for prototyping, that is pretty useless, and just gets in the way of using that generated data for anything. Could we implement something to suppress multiple of the same terms on an a node entity for the sanity of folks making views and filters with generated content?

#11

This issue is made much more annoying by the not so random selection of terms, which I've tried to fix here #1328380: Patch: Fixing fact that certain tax terms are nearly always selected by devel_generate

#12

Just ran into this myself for the first time. Not sure how a user could go about purposefully sending the same term multiple times, but my devel generated nodes definitely do it. Screenshot attached.

AttachmentSizeStatusTest resultOperations
devel-generate-duplicate-terms-single-node.png61.4 KBIgnored: Check issue status.NoneNone

#13

I don't doubt that this happens, I just haven't seen any convincing patch yet.