Change scheme for the google maps api call to https and include an api key if one was set#10439
Change scheme for the google maps api call to https and include an api key if one was set#10439rdeutz merged 8 commits intojoomla:stagingfrom matrikular:patch-12
Conversation
While the main change to this file is about setting the scheme to https, I've also refactored the uri handling and added the option to apply an api key as well.
…ors with e.g. isSercure()
Remove the sensor parameter since it doesn't seem to be need any longer. Thanks for pointing it out @robert.
|
@mbabker is this a PR that should be made to the framework as well / instead ? This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10439. |
…rely on it Add the sensor parameter back to the api url since the tests seem to rely on it. If that really is the case, we should implement be a better way of "parsing" the url and / or looking for an array index in the tests.
This time the test(s) shouldn't fail - fingers crossed.
|
Works as described. Fixes a problem I have had. Thanx for the patch. |
|
I have tested this item ✅ successfully on fd2305c This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10439. |
|
MERGER - I am setting this RTC but not sure if should be merged here or in the upstream package? This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10439. |
|
Yes it needs to be merged here because the CMS isn't using any of the HTTP adapter code (which includes all of the API packages) from the Framework. |
|
Thanks for confirming @mbabker
|
|
IMHO it would be a good practice to make this change also in the joomla framework repository |
|
Should be fixed there, yes. But since it's not a Composer pulled library here, it should be merged here and dealt with on the FW separately. |
|
@mbabker yes of course. This is RTC and can be merged. @matrikular can you do a PR also in the framework repository? |
|
Not sure if it has got the correct format, but - of course - here you go: #10. |
|
@joomla-cms-bot. This here is one more to fix :P |
Summary of Changes
This PR changes the api scheme / protocol for the geocodeAddress call to https instead of http. Currently the JGoogleEmbedMaps::geocodeAddress() api call uses http.
Though, e.g. if you call the api url directly, google redirects you to https, an exception will be returned from google when using the api together with an api key without using https.
Speaking of the api key; The google library allows you to set an api key that will be used in the javascript rendering part but not in the geocodeAddress() method. This PR also adds a key to the request if present so that you won't run into your quota limit any time soon.
Testing Instructions
Download and install the test modul I attached to this PR. Enable the module, assign it to e.g. the position-3 of the protostar template. Don't forget to set the module to show on all pages.
Depending on the settings (key, address) you've made, you will see a debug message with information about the last request. Now, there aren't really that much visible errors to indicate something not working correctly. The debug message in the module only show that the request works as before.
You can provoke the exception mentioned above by applying the patch and changing the https back to http on line 785 in /libraries/joomla/google/embed/maps.php. Given you've provided an api key you would see a message similar to this one:

Attachment
mod_geocodepr.zip