Problem/Motivation

D6 taxonomy vocabularies have two settings (tags, and multiple) that are related to field cardinality. The descriptions for the fields are the following.

Tags: Terms are created by users when submitting posts by typing a comma separated list.
Multiple: Allows posts to have more than one term from this vocabulary (always true for tags).

(Source: http://cgit.drupalcode.org/drupal/tree/modules/taxonomy/taxonomy.admin.i...)

Proposed resolution

Set field cardinality to Unlimited if tags or multiple is enabled, otherwise 1.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webflo created an issue. See original summary.

webflo’s picture

Status: Active » Needs review
Issue tags: +rc eligible
webflo’s picture

webflo’s picture

FileSize
3.98 KB

The last submitted patch, 3: 2616220-2.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 4: 2616220-4.patch, failed testing.

webflo’s picture

Status: Needs work » Needs review
FileSize
4.36 KB

I had to change the db dump because there are node revisions with multiple terms.

Status: Needs review » Needs work

The last submitted patch, 7: 2616220-7.patch, failed testing.

The last submitted patch, 7: 2616220-7.patch, failed testing.

webflo’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: 2616220-7.patch, failed testing.

webflo’s picture

Status: Needs work » Needs review
benjy’s picture

Thanks, patch and tests look good, RTBC for me, just one small thing:

+++ b/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php
@@ -72,6 +72,7 @@ public function prepareRow(Row $row) {
+    $row->setSourceProperty('cardinality', ($row->getSourceProperty('tags') == 1 || $row->getSourceProperty('multiple') == 1) ? -1 : 1);

Shall we add a constant for "1" here?

quietone’s picture

Issue tags: +migrate-d6-d8
quietone’s picture

What is the advantage of adding a constant for 1?

I think this should use the constant for unlimited cardinality.

benjy’s picture

Status: Needs review » Reviewed & tested by the community

Sorry, -1 makes much more sense. RTBC

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/taxonomy/tests/src/Unit/Migrate/d6/VocabularyTest.php
@@ -39,6 +39,7 @@ class VocabularyTest extends MigrateSqlSourceTestCase {
+      'cardinality' => -1,

This should also use the constant.

quietone’s picture

Status: Needs work » Needs review
FileSize
4.9 KB
776 bytes

Yes, it should.

benjy’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -rc eligible

Great

  • catch committed e660168 on 8.2.x
    Issue #2616220 by webflo, quietone: Obey field cardinality in vocabulary...

  • catch committed 5bf8ff7 on 8.0.x
    Issue #2616220 by webflo, quietone: Obey field cardinality in vocabulary...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to all three 8.x branches, thanks!

Adding review credit post-commit.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.