Commit 70938aed authored by Eric Goodwin's avatar Eric Goodwin Committed by Italo Mairo
Browse files

Issue #3264184 by Eric115: Static value in GeofieldProximityArgument causes...

Issue #3264184 by Eric115: Static value in GeofieldProximityArgument causes incorrect results when view rendered more than once
parent 6b154395
Loading
Loading
Loading
Loading
+10 −17
Original line number Diff line number Diff line
@@ -205,14 +205,10 @@ class GeofieldProximityArgument extends Formula implements ContainerFactoryPlugi
   *   The calculated values.
   */
  public function getParsedReferenceLocation() {
    // Cache the vales so this only gets processed once.
    static $values;

    if (!isset($values)) {
    // Process argument values into an array.
    preg_match('/^([0-9\-.]+),+([0-9\-.]+)([<>=]+)([0-9.]+)(.*$)/', trim($this->getValue()), $values);
    // Validate and return the passed argument.
      $values = is_array($values) && !empty($values) ? [
    return is_array($values) && !empty($values) ? [
      'lat' => (isset($values[1]) && is_numeric($values[1]) && $values[1] >= -90 && $values[1] <= 90) ? floatval($values[1]) : FALSE,
      'lon' => (isset($values[2]) && is_numeric($values[2]) && $values[2] >= -180 && $values[2] <= 180) ? floatval($values[2]) : FALSE,
      'operator' => (isset($values[3]) && in_array($values[3], [
@@ -226,9 +222,6 @@ class GeofieldProximityArgument extends Formula implements ContainerFactoryPlugi
      'distance' => (isset($values[4])) ? floatval($values[4]) : FALSE,
      'units' => (isset($values[5]) && array_key_exists($values[5], $this->units)) ? $this->units[$values[5]]['value'] : 'GEOFIELD_KILOMETERS',
    ] : FALSE;

    }
    return $values;
  }

}