Steps to reproduce:
1. Add media field (reference) to any content type
2. Make this media field not required
3. Access /jsonapi/node/{content_type}/{uuid}/{media_field}

See:
Notice: Undefined offset: 0 in /web/modules/contrib/jsonapi_extras/modules/jsonapi_defaults/src/Controller/EntityResource.php on line 143

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dmitry.korhov created an issue. See original summary.

dmitry.korhov’s picture

dmitry.korhov’s picture

Status: Active » Needs review
bbrala’s picture

Status: Needs review » Needs work
+++ b/modules/jsonapi_defaults/src/Controller/EntityResource.php
@@ -140,7 +140,7 @@ class EntityResource extends JsonApiEntityResourse {
-    return $relatable_resource_types[0];
+    return reset($relatable_resource_types);

Doesn't this change what is returned? Before it would return NULL not FALSE like it does now.

S_Bhandari’s picture

Hi,

Working on it. I Will update as soon as possible.

Thanks.

bbrala’s picture

Awesome! Thanks!

S_Bhandari’s picture

Status: Needs work » Needs review
FileSize
571 bytes
489 bytes

Hi,

Added a patch and interdiff for the same. Please review it and let me know for any observation.

Thanks.

  • bbrala committed 6139150 on 8.x-3.x authored by S_Bhandari
    Issue #3112495 by S_Bhandari, dmitry.korhov, bbrala: Notice: Undefined...
bbrala’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

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