Skip to content

Commit

Permalink
[Bugfix] Fix multiple undefined array keys
Browse files Browse the repository at this point in the history
  • Loading branch information
zoglo committed Nov 2, 2022
1 parent fab4a02 commit bd7f352
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
14 changes: 9 additions & 5 deletions src/Resources/contao/classes/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public function setLocationParameter(&$arrColumns, &$arrValues, &$arrOptions, $m

$t = $this->strTable;

if ($_SESSION['FILTER_DATA']['radius-google'] && $_SESSION['FILTER_DATA']['latitude'] && $_SESSION['FILTER_DATA']['longitude'])
if (
($_SESSION['FILTER_DATA']['radius-google'] ?? null) &&
($_SESSION['FILTER_DATA']['latitude'] ?? null) &&
($_SESSION['FILTER_DATA']['longitude'] ?? null)
)
{
$arrColumns[] = "(6371*acos(cos(radians(?))*cos(radians($t.breitengrad))*cos(radians($t.laengengrad)-radians(?))+sin(radians(?))*sin(radians($t.breitengrad)))) <= ?";
$arrValues[] = $_SESSION['FILTER_DATA']['latitude'];
Expand All @@ -52,26 +56,26 @@ public function setLocationParameter(&$arrColumns, &$arrValues, &$arrOptions, $m
}
else
{
if ($_SESSION['FILTER_DATA']['city'])
if ($_SESSION['FILTER_DATA']['city'] ?? null)
{
$arrColumns[] = "$t.ort=?";
$arrValues[] = $_SESSION['FILTER_DATA']['city'];
}

if ($_SESSION['FILTER_DATA']['postal'])
if ($_SESSION['FILTER_DATA']['postal'] ?? null)
{
$arrColumns[] = "$t.plz=?";
$arrValues[] = $_SESSION['FILTER_DATA']['postal'];
}

if ($_SESSION['FILTER_DATA']['district'])
if ($_SESSION['FILTER_DATA']['district'] ?? null)
{
$arrColumns[] = "$t.regionalerZusatz=?";
$arrValues[] = $_SESSION['FILTER_DATA']['district'];
}
}

if ($objModule->type === 'realEstateResultList' && $objModule->googleFilterAddSorting && $_SESSION['SORTING'] === 'location')
if (isset($objModule) && $objModule->type === 'realEstateResultList' && $objModule->googleFilterAddSorting && ($_SESSION['SORTING'] ?? null) === 'location')
{
if ($objModule->googleFilterLat && $objModule->googleFilterLng)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Resources/contao/filters/FilterLocationGoogle.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ public function __set($strKey, $varValue)
*/
public function parse($arrAttributes=null): string
{
$this->value = $_SESSION['FILTER_DATA']['location-google'];
$this->valueCountry = $_SESSION['FILTER_DATA']['country-short'];
$this->valueCity = $_SESSION['FILTER_DATA']['city'];
$this->valuePostal = $_SESSION['FILTER_DATA']['postal'];
$this->valueDistrict = $_SESSION['FILTER_DATA']['district'];
$this->valueLatitude = $_SESSION['FILTER_DATA']['latitude'];
$this->valueLongitude = $_SESSION['FILTER_DATA']['longitude'];
$this->value = $_SESSION['FILTER_DATA']['location-google'] ?? null;
$this->valueCountry = $_SESSION['FILTER_DATA']['country-short'] ?? null;
$this->valueCity = $_SESSION['FILTER_DATA']['city'] ?? null;
$this->valuePostal = $_SESSION['FILTER_DATA']['postal'] ?? null;
$this->valueDistrict = $_SESSION['FILTER_DATA']['district'] ?? null;
$this->valueLatitude = $_SESSION['FILTER_DATA']['latitude'] ?? null;
$this->valueLongitude = $_SESSION['FILTER_DATA']['longitude'] ?? null;

$types = $this->googleAutocompleteType === 'regions' ? '('.$this->googleAutocompleteType.')' : $this->googleAutocompleteType;

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/contao/filters/FilterRadiusGoogle.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function parse($arrAttributes=null): string
$arrOptions[] = array
(
'value' => $value,
'selected' => $value === $_SESSION['FILTER_DATA']['radius-google'] ? ' selected' : '',
'selected' => $value === ($_SESSION['FILTER_DATA']['radius-google'] ?? null) ? ' selected' : '',
'label' => $value.' km'
);
}
Expand Down

0 comments on commit bd7f352

Please sign in to comment.