Uploaded image for project: 'eZ Platform Enterprise Edition'
  1. eZ Platform Enterprise Edition
  2. EZEE-2561

LocationListBlockAttributeRelationExtractor crashes when location does not exist anymore

    XMLWordPrintable

Details

    Description

      Hello,

      Explanation and reproduction are pretty simple.
      Create a CollectionList block, add few locations and publish.

      Then remove one of the locations you associated in the Block

      Result: it is crashing the page entirely.

      Debug:

      vendor/ezsystems/ezplatform-page-fieldtype/src/lib/FieldType/Page/Block/Relation/Extractor/LocationListBlockAttributeRelationExtractor.php (line 54)

      public function extract(
              Page $page,
              BlockValue $blockValue,
              BlockAttributeDefinition $attributeDefinition,
              Attribute $attribute
          ): array {
              $contentIds = [];
              if (!empty($attribute->getValue())) {
                  $locationIds = explode(',', $attribute->getValue());
                  $locations = array_map([$this->locationService, 'loadLocation'], $locationIds);
                  $contentIds = array_column($locations, 'contentId');
              }
      
              return array_unique(array_map('intval', $contentIds));
          }
      

      This is wrong:

      $locations = array_map([$this->locationService, 'loadLocation'], $locationIds);
      

      some kind of tests must be done.

      Also I think the error could also be fixed by removing the locationId from the list when the actual location is removed.

      Thx!

      Attachments

        Activity

          People

            Unassigned Unassigned
            2bfcc1b1-0b8e-4fb5-9c24-c434957abb69@accounts.ibexa.co Sébastien Morel
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: