The committed patch in https://www.drupal.org/node/2778923 introduced a bug.

If the cardinality of a field is Unlimited (= -1) then the count will be something like -3 and you have a validation error.

Here is the patch that fixed the bug of the already commited patch:

Only change the count of the cardinality if its not unlimited..

Comments

ayalon created an issue. See original summary.

ayalon’s picture

StatusFileSize
new870 bytes
ayalon’s picture

StatusFileSize
new1.26 KB
slashrsm’s picture

Status: Active » Needs review
Issue tags: +D8Media
slashrsm’s picture

Status: Needs review » Needs work

Good catch! Thank you for the patch.

+  $cardinality = -1;
+  if($instance->getFieldStorageDefinition()->get('cardinality') !== $cardinality) {
+    $cardinality = $instance->getFieldStorageDefinition()->get('cardinality') - $count_existing_selection;
+  }
+

There is a constant for that (FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) and we should use it. A comment explaining the purpose of this hunk would be nice.

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

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

ayalon’s picture

StatusFileSize
new1.15 KB
ayalon’s picture

Here is a patch with the constant

ayalon’s picture

ayalon’s picture

StatusFileSize
new1.46 KB

My patch tool hates ma today: Here is another attempt:

slashrsm’s picture

Status: Needs work » Needs review

  • slashrsm committed 8a7aeca on 8.x-1.x authored by ayalon
    Issue #2799299 by ayalon: Correclty handle unlimited cardinality in...
slashrsm’s picture

Status: Needs review » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

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