I have a block on a commerce product page, this block displays the product entity with a specific display set up to just show the map. After the recent updates, when the product has no locations, I get a PHP error:

Fatal error: Call to a member function getValue() on null in web/modules/contrib/geolocation/modules/geolocation_google_maps/src/Plugin/Field/FieldFormatter/GeolocationGoogleMapFormatter.php on line 75

Basically this bit of code doesn't properly check that an element exists when trying to render:

if (
      $settings['use_overridden_map_settings']
      && !empty($items->get(0)->getValue()['data'][$this->mapProviderSettingsFormId])
      && is_array($items->get(0)->getValue()['data'][$this->mapProviderSettingsFormId])
    )

Comments

willeaton created an issue. See original summary.

willeaton’s picture

Status: Active » Needs review
StatusFileSize
new695 bytes

Patch attached with possible fix.

Status: Needs review » Needs work

The last submitted patch, 2: geolocation-2991198.patch, failed testing. View results

willeaton’s picture

StatusFileSize
new823 bytes

OK, patch now created from main module root rather than sub module root

willeaton’s picture

Status: Needs work » Needs review

Updating status to test patch again

Status: Needs review » Needs work

The last submitted patch, 4: geolocation-2991198-2.patch, failed testing. View results

christianadamski’s picture

Your patch failes, because you wrote against beta-1 instead of -dev

christianadamski’s picture

Status: Needs work » Needs review
StatusFileSize
new660 bytes

  • willeaton authored f7d52fa on 8.x-2.x
    Issue #2991198 by willeaton: PHP error when no points available
    
christianadamski’s picture

Status: Needs review » Fixed

Thanks Will.

Status: Fixed » Closed (fixed)

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