From 90e926415080d0d3487ae046fe4eb3d0bec8460b Mon Sep 17 00:00:00 2001 From: reswild Date: Fri, 17 Jul 2020 16:01:01 +0100 Subject: [PATCH 1/2] Switch from HTTP_Request to GuzzleHttp\Client --- CRM/Utils/Geocode/OpenStreetMapCoding.php | 27 ++++++----------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/CRM/Utils/Geocode/OpenStreetMapCoding.php b/CRM/Utils/Geocode/OpenStreetMapCoding.php index ec0738e..af880b0 100644 --- a/CRM/Utils/Geocode/OpenStreetMapCoding.php +++ b/CRM/Utils/Geocode/OpenStreetMapCoding.php @@ -135,36 +135,23 @@ static function format(&$values, $stateName = FALSE) { $url .= '&' . urlencode($key) . '=' . urlencode($value); } - $result = $request = null; - try { - require_once 'HTTP/Request.php'; - $request = new HTTP_Request($url); - $result = $request->sendRequest(); - } catch(Exception $e) { - // this could happen if there is a connection error or the server shut you out - // see: https://github.com/systopia/de.systopia.osm/issues/8 - CRM_Core_Error::debug_log_message('Geocoding failed: ' . $e->getMessage()); - return FALSE; - } + $client = new GuzzleHttp\Client(); + $request = $client->request('GET', $url); // check if request was successful - if (PEAR::isError($result)) { - CRM_Core_Error::debug_log_message('Geocoding failed: ' . $result->getMessage()); - return FALSE; - } - if ($request->getResponseCode() != 200) { - CRM_Core_Error::debug_log_message('Geocoding failed, invalid response code ' . $request->getResponseCode()); - if ($request->getResponseCode() == 429) { + if ($request->getStatusCode() != 200) { + CRM_Core_Error::debug_log_message('Geocoding failed, invalid response code ' . $request->getStatusCode()); + if ($request->getStatusCode() == 429) { // provider says 'TOO MANY REQUESTS' $values['geo_code_error'] = 'OVER_QUERY_LIMIT'; } else { - $values['geo_code_error'] = $request->getResponseCode(); + $values['geo_code_error'] = $request->getStatusCode(); } return FALSE; } // process results - $string = $request->getResponseBody(); + $string = $request->getBody(); $json = json_decode($string); if (is_null($json) || !is_array($json)) { From 08dae310aaddc95618d56d50865a1af6f427ba70 Mon Sep 17 00:00:00 2001 From: reswild Date: Wed, 22 Jul 2020 23:54:24 +0100 Subject: [PATCH 2/2] Set compatibility to version 5 only --- info.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/info.xml b/info.xml index c36061e..43fa50e 100644 --- a/info.xml +++ b/info.xml @@ -12,10 +12,6 @@ 1.2.1 stable - 4.4 - 4.5 - 4.6 - 4.7 5.0