From 795153b213121c6ec8cc725451d4f20c307b4174 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 8 Oct 2017 16:42:04 +0200 Subject: [PATCH] fix more syntax issues --- lib/Geocode.php | 15 +++++++++------ lib/SearchDescription.php | 16 ++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/Geocode.php b/lib/Geocode.php index 33b02d2b..2f265111 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -741,12 +741,15 @@ class Geocode // If the token is valid if (isset($aValidTokens[' '.$sToken])) { - // Recheck if the original word shows up in the query. - $bWordInQuery = false; - if (isset($aSearchTerm['word']) && $aSearchTerm['word']) { - $bWordInQuery = $this->normTerm($aSearchTerm['word']) !== false; - } foreach ($aValidTokens[' '.$sToken] as $aSearchTerm) { + // Recheck if the original word shows up in the query. + $bWordInQuery = false; + if (isset($aSearchTerm['word']) && $aSearchTerm['word']) { + $bWordInQuery = strpos( + $sNormQuery, + $this->normTerm($aSearchTerm['word']) + ) !== false; + } $aNewSearches = $oCurrentSearch->extendWithFullTerm( $aSearchTerm, $bWordInQuery, @@ -1180,7 +1183,7 @@ class Geocode ); } elseif ($oSearch->isOperator(Operator::POSTCODE)) { $aPlaceIDs = $oSearch->queryPostcode( - $oDB, + $this->oDB, $sCountryCodesSQL, $this->iLimit ); diff --git a/lib/SearchDescription.php b/lib/SearchDescription.php index a8285299..b7b4498d 100644 --- a/lib/SearchDescription.php +++ b/lib/SearchDescription.php @@ -20,7 +20,7 @@ abstract class Operator /// Search for postcodes. const POSTCODE = 5; - private $aConstantNames = null; + private static $aConstantNames = null; public static function toString($iOperator) { @@ -28,17 +28,17 @@ abstract class Operator return ''; } - if ($aConstantNames === null) { + if (Operator::$aConstantNames === null) { $oReflector = new \ReflectionClass ('Nominatim\Operator'); $aConstants = $oReflector->getConstants(); - $aConstantNames = array(); + Operator::$aConstantNames = array(); foreach ($aConstants as $sName => $iValue) { - $aConstantNames[$iValue] = $sName; + Operator::$aConstantNames[$iValue] = $sName; } } - return $aConstantNames[$iOperator]; + return Operator::$aConstantNames[$iOperator]; } } @@ -322,7 +322,7 @@ class SearchDescription } $oSearch->setPoiSearch($iOp, $aSearchTerm['class'], $aSearchTerm['type']); - $aNewWordsetSearches[] = $oSearch; + $aNewSearches[] = $oSearch; } } elseif (isset($aSearchTerm['word_id']) && $aSearchTerm['word_id']) { $iWordID = $aSearchTerm['word_id']; @@ -501,10 +501,10 @@ class SearchDescription $sSQL .= 'WHERE '; } - $sSQL .= "p.postcode = '".pg_escape_string(reset($this->$aName))."'"; + $sSQL .= "p.postcode = '".pg_escape_string(reset($this->aName))."'"; $sCountryTerm = $this->countryCodeSQL('p.country_code', $sCountryList); if ($sCountryTerm) { - $sSQL .= ' AND '.$sCountyTerm; + $sSQL .= ' AND '.$sCountryTerm; } $sSQL .= " LIMIT $iLimit"; -- 2.39.5