Error: Call to a member function getParsedReferenceLocation() on array in Drupal\geofield\Plugin\GeofieldProximitySource\ContextProximityFilter->getOrigin() (line 79 o

Created on 14 October 2022, over 1 year ago
Updated 24 November 2023, 7 months ago

Problem/Motivation

Error: Call to a member function getParsedReferenceLocation() on array in Drupal\geofield\Plugin\GeofieldProximitySource\ContextProximityFilter->getOrigin() (line 79

Steps to reproduce

ContextProximityFilter is running on views where there is no argument of type GeofieldProximityArgument.

public function getOrigin() {
    $origin = [];
    if (isset($this->viewHandler)) {
      /** @var \Drupal\geofield\Plugin\views\argument\GeofieldProximityArgument $geofield_proximity_argument */
      $geofield_proximity_argument = $this->viewHandler->view->argument;
      foreach ($this->viewHandler->view->argument as $argument) {
        if ($argument instanceof GeofieldProximityArgument) {
          $geofield_proximity_argument = $argument;
        }
      }

      if (isset($geofield_proximity_argument) && $argument_values = $geofield_proximity_argument->getParsedReferenceLocation()) {
        $origin = [
          'lat' => $argument_values['lat'],
          'lon' => $argument_values['lon'],
        ];
      }
    }
    return $origin;

If no argument from the view handler is an instance of GeofieldProximityArgument then $geofield_proximity_argument is incorrectly set to the array of arguments from the view handler.

Proposed resolution

Set $geofield_proximity_argument to NULL initially. A patch and MR to follow shortly.

Remaining tasks

Review.

User interface changes

None.

API changes

None.

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland tcrawford

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024