]> git.openstreetmap.org Git - nominatim.git/commitdiff
correctly handle comma-only exclude_place_ids
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 29 Mar 2015 16:17:52 +0000 (18:17 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 29 Mar 2015 16:17:52 +0000 (18:17 +0200)
lib/Geocode.php
tests/features/api/search_simple.feature
tests/steps/api_result.py

index dfb3af2ae823c60eabe816bcc3af2d6c7bb651f1..a7adb2b98a06fe1f3fd6d05ae053f4621dcbcb13 100644 (file)
                                foreach(explode(',',$aParams['exclude_place_ids']) as $iExcludedPlaceID)
                                {
                                        $iExcludedPlaceID = (int)$iExcludedPlaceID;
-                                       if ($iExcludedPlaceID) $aExcludePlaceIDs[$iExcludedPlaceID] = $iExcludedPlaceID;
+                                       if ($iExcludedPlaceID)
+                                               $aExcludePlaceIDs[$iExcludedPlaceID] = $iExcludedPlaceID;
                                }
-                               $this->aExcludePlaceIDs = $aExcludePlaceIDs;
+
+                               if (isset($aExcludePlaceIDs))
+                                       $this->aExcludePlaceIDs = $aExcludePlaceIDs;
                        }
 
                        // Only certain ranks of feature
index 9c796e99d9ab46628c02dc3bb7d966ced1f9f039..3e6b6e35b80fb85ccd4d6448b9979063799564d2 100644 (file)
@@ -166,6 +166,13 @@ Feature: Simple Tests
           | attr              | value
           | exclude_place_ids | 123,76,342565
 
+    Scenario: Empty XML search with bad exluded place ids
+        Given the request parameters
+          | exclude_place_ids
+          | ,
+        When sending xml search query "jghrleoxsbwjer"
+        Then result header has no attribute exclude_place_ids
+
     Scenario Outline: Wrapping of legal jsonp search requests
         Given the request parameters
           | json_callback
index d83aa83deb4081928673ff101cbce410675ebf8d..369127d861d6e0e1b79b777008a57a45fcca9982 100644 (file)
@@ -143,6 +143,11 @@ def api_result_header_contains(step):
         assert_in(line['attr'], world.result_header)
         m = re.match("%s$" % (line['value'],), world.result_header[line['attr']])
 
+@step(u'result header has no attribute (.*)')
+def api_result_header_contains_not(step, attr):
+    step.given('the result is valid')
+    assert_not_in(attr, world.result_header)
+
 @step(u'results contain$')
 def api_result_contains(step):
     step.given('at least 1 result is returned')