See parent issue #3200985: [meta] Fix undesirable access checking on entity query usages for context and test coverage policy.

Drupal's field_ui module allows sitebuilders to specify the cardinality of a field, the number of allowed values in that field on a single entity. When changing this setting to specify a reduced number of allowed values, for an entity type that has existing data, FieldStorageConfigEditForm::validateCardinality checks that there are not already entities that exceed the new number of allowed values.

This check should not be access sensitive.

Issue fork drupal-3202440

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jonathanshaw created an issue. See original summary.

jonathanshaw’s picture

Status: Active » Needs review
longwave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for working on these - the fix is good and the test is great!

I was going to suggest avoiding t() in the assertRaw() call as elsewhere we are trying to remove t(), but as you're following the convention used earlier in the same test I think it's OK to add this here and then clean it all up in one go in the future.

  • catch committed af01411 on 9.2.x
    Issue #3202440 by jonathanshaw, longwave: EntityQuery accessCheck: field...

  • catch committed 82fe153 on 9.1.x
    Issue #3202440 by jonathanshaw, longwave: EntityQuery accessCheck: field...
catch’s picture

Title: EntityQuery accessCheck: field ui cardinality validation should not be access sensitive » [backport] EntityQuery accessCheck: field ui cardinality validation should not be access sensitive
Version: 9.2.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Committed/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!

This should probably go into 8.9.x too, but it needs a re-roll/rebase there.

ravi.shankar’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
3.94 KB

Added reroll for Drupal 8.9.x.

jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community
renatog’s picture

Status: Reviewed & tested by the community » Needs work

This comment has more than 80 chars, please split it into a second line
// Remove the cardinality limit 4 so we can add a node the user doesn't have access to.
Example:

// Remove the cardinality limit 4 so we can add a node the user doesn't have
// access to.
ravi.shankar’s picture

Status: Needs work » Needs review
FileSize
3.95 KB
794 bytes

Addressed comment #10.

jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community
renatog’s picture

Thanks, really works well. +1 to it

  • catch committed c2af52f on 8.9.x
    Issue #3202440 by jonathanshaw, ravi.shankar, catch, longwave: [backport...
catch’s picture

Status: Reviewed & tested by the community » Fixed
+++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
@@ -344,6 +351,47 @@ public function cardinalitySettings() {
+
+    // Assert that you can't set the cardinality to a lower number then the
+    // highest delta of this field (including inaccessible entities) but can
+    // set it to the same.

*than the highest delta (fixed on commit).

Committed c2af52f and pushed to 8.9.x. Thanks!

catch’s picture

Status: Fixed » Closed (fixed)

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