Problem/Motivation

#2800873: Add XML GET REST test coverage, work around XML encoder quirks introduced a new test field: field_rest_test_multivalue. This is fine.

Unfortunately, it did not get the same special treatment as field_rest_test, which got this:

      case 'view':
        // Never ever allow this field to be viewed: this lets EntityResourceTestBase::testGet() test in a "vanilla" way.
        return AccessResult::forbidden();

This prevented that field from showing up in normalizations, which meant that each entity type could still write its own GET test coverage without it needing to be aware of this automatically added field (that is used for testing certain edge cases).

Proposed resolution

Also disallow view access for the field_rest_test_multivalue field.

Remaining tasks

Patch.

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new6.41 KB

Status: Needs review » Needs work

The last submitted patch, 3: 2928702-3.patch, failed testing. View results

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs work » Needs review
StatusFileSize
new6.32 KB

#3 was on top of another patch. My bad. Rebased, unchanged.

borisson_’s picture

Status: Needs review » Needs work

Nitpicks:

  1. +++ b/core/modules/rest/tests/modules/rest_test/rest_test.module
    @@ -27,6 +28,16 @@ function rest_test_entity_field_access($operation, FieldDefinitionInterface $fie
    +    switch ($operation) {
    +      case 'view':
    

    I don't understand why this is a switch, this can be a simple if instead.

  2. +++ b/core/modules/rest/tests/modules/rest_test/rest_test.module
    @@ -27,6 +28,16 @@ function rest_test_entity_field_access($operation, FieldDefinitionInterface $fie
    +        // Never ever allow this field to be viewed: this lets EntityResourceTestBase::testGet() test in a "vanilla" way.
    

    80 cols.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new1.48 KB
new6.59 KB

Thanks for the review!

  1. Consistency with the code just before it.
  2. Fixed. Also fixed the occurrence of the exact same comment in the code just before it.
tedbow’s picture

Status: Needs review » Reviewed & tested by the community

@Wim Leers looks good. This will make other tests easier to understand!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2928702-7.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Reviewed & tested by the community

Retesting because #7 got

exception: [Warning] Line 179 of core/lib/Drupal/Core/Cache/ApcuBackend.php:
apcu_store(): Unable to allocate memory for pool.

Errors, so pretty sure unrelated DrupalCI errors.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2928702-7.patch, failed testing. View results

borisson_’s picture

Status: Needs work » Reviewed & tested by the community

Same error as in #11.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2928702-7.patch, failed testing. View results

wim leers’s picture

Status: Needs work » Reviewed & tested by the community

This is maddening.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Very nice clean-up, and simply applying patterns from elsewhere in core to here.

Committed and pushed to 8.5.x. Thanks!

  • webchick committed ee22a47 on 8.5.x
    Issue #2928702 by Wim Leers, borisson_, tedbow: Make...

Status: Fixed » Closed (fixed)

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