Skip to content
Snippets Groups Projects
Verified Commit bb6903e8 authored by Dave Long's avatar Dave Long
Browse files

Issue #3377269 by _tarik_, ReINFaTe, smustgrave, bbrala: Warning: Undefined...

Issue #3377269 by _tarik_, ReINFaTe, smustgrave, bbrala: Warning: Undefined array key "id" in Drupal\jsonapi\Controller\EntityResource->patchIndividual()

(cherry picked from commit b930619b)
parent ae84c94c
Branches
Tags
11 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...
Pipeline #89756 passed
Pipeline: drupal

#89779

    Pipeline: drupal

    #89770

      Pipeline: drupal

      #89765

        +1
        ......@@ -315,11 +315,11 @@ public function patchIndividual(ResourceType $resource_type, EntityInterface $en
        $body = Json::decode($request->getContent());
        $data = $body['data'];
        if ($data['id'] != $entity->uuid()) {
        if (!isset($data['id']) || $data['id'] != $entity->uuid()) {
        throw new BadRequestHttpException(sprintf(
        'The selected entity (%s) does not match the ID in the payload (%s).',
        $entity->uuid(),
        $data['id']
        $data['id'] ?? '',
        ));
        }
        $data += ['attributes' => [], 'relationships' => []];
        ......
        ......@@ -2200,6 +2200,10 @@ public function testPatchIndividual() {
        if ($this->entity instanceof FieldableEntityInterface && $this->entity->hasField('field_jsonapi_test_entity_ref')) {
        $parseable_invalid_request_body_5 = Json::encode(NestedArray::mergeDeep(['data' => ['attributes' => ['field_jsonapi_test_entity_ref' => ['target_id' => $this->randomString()]]]], $this->getPostDocument()));
        }
        // Invalid PATCH request with missing id key.
        $parseable_invalid_request_body_6 = $this->getPatchDocument();
        unset($parseable_invalid_request_body_6['data']['id']);
        $parseable_invalid_request_body_6 = Json::encode($parseable_invalid_request_body_6);
        // The URL and Guzzle request options that will be used in this test. The
        // request options will be modified/expanded throughout this test:
        ......@@ -2304,6 +2308,12 @@ public function testPatchIndividual() {
        $this->assertResourceErrorResponse(422, "The following relationship fields were provided as attributes: [ field_jsonapi_test_entity_ref ]", $url, $response, FALSE);
        }
        // DX: 400 when request document doesn't contain id.
        // This also tests that no PHP warnings raised due to non-existent key.
        $request_options[RequestOptions::BODY] = $parseable_invalid_request_body_6;
        $response = $this->request('PATCH', $url, $request_options);
        $this->assertResourceResponse(400, FALSE, $response);
        // 200 for well-formed PATCH request that sends all fields (even including
        // read-only ones, but with unchanged values).
        $valid_request_body = NestedArray::mergeDeep($this->normalize($this->entity, $url), $this->getPatchDocument());
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment