pimcore / data-hub

Data delivery & consumption platform for Pimcore.
Other
126 stars 108 forks source link

[Bug]: Undefined array index not checked in Block Fields #519

Closed HageMaster3108 closed 2 years ago

HageMaster3108 commented 2 years ago

Expected behavior

In Debug mode, retrieving a block field value for a block field which never had a value, I'd expect it to return null (or an empty string).

Actual behavior

Instead, it gives me Warning: undefined array key "fieldname".

Steps to reproduce

I have a query

  getOrthomolCorporateProductDosageFormListing(defaultLanguage: "de_DE") {
   edges {
     node {
       id
       name(language: "de_DE")
       packsizes {
         size
         PZN
         EAN
         oNumber
         snapnextId
         b2cAppPoints
         packshot { # this is an asset field
           fullpath
           srcset(thumbnail: "PictureText") {
             url
             descriptor
           }
         }
       }
     }
   }
  }
}

In this model OrthomolCorporateProductDosageForm has a block packsizes. If I have one of these fields unset (never had a value) the serialized data in the db for that block is missing the array key (e.g. packshot).

If now I run pimcore in debug mode, datahub tries to access the array key nevertheless in BlockEntryType.php Line 136

So what's missing there is

if (!array_key_exists($resolveInfo->fieldName, $value)) {
    return null;
}

I'd have sent a PR right a way but currently github says "no more forks can be created" for this repo?

HageMaster3108 commented 2 years ago

Ah, found that I couldn't fork because I already had a fork :-P :-P 🤦 So now updated my fork and created a PR, see above ;-)

HageMaster3108 commented 2 years ago

BTW, Root cause for the issue found by @SaschaHowe