[Resolved] Google Maps working fine, but nothing is being cached

This thread is resolved. Here is a description of the problem and solution.

Problem: Google Maps is working fine but nothing is being cached in Toolset > Settings > Maps.

Solution: Upgrade MySQL to 5.6+ to get access to all maps features.

Relevant Documentation: https://toolset.com/toolset-requirements/

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 7 replies, has 2 voices.

Last updated by markP-18 3 months ago.

Assigned support staff: Christian Cox.

Author
Posts
#1560003

I am trying to:
Limit the amount of API calls that the site makes to Google Maps API
Link to a page where the issue can be seen:
hidden link
shows that there is no cached data.
I expected to see:
a list of cached maps data
Instead, I got:
an empty list

When I look in the database at the wp_toolset_maps_address_cache table, there are no rows in the table. Even if I have just successfully been performing address lookups on a map within a Toolset custom post type.

The map integration is working perfectly, it just doesn't seem to be caching any data for re-use.

My Google Cloud console is showing that I'm making a couple of thousand API calls per day - and the credentials used are restricted to the website in question.

#1560427

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Hello, I'll be glad to take a look at this. First, please go to Toolset > Settings > Maps and click the "Check API" button in the Google Map API Key section. Let me know the response you get - it's possible that some of the APIs are working as expected but others are not, and this should let me know. If everything checks out okay, let's try to determine if any server-side errors are registered by your site during the API request and address caching processes. If you're not familiar with server logs, I can show you how to active one temporarily. Go in your wp-config.php file and look for

define('WP_DEBUG', false);

Change it to:

define('WP_DEBUG', true);

Then add these lines, just after the WP_DEBUG line:

define('WP_DEBUG_LOG', dirname(__FILE__) . '/error_log.txt');
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
define('WP_DISABLE_FATAL_ERROR_HANDLER',true);

Now, use the address field in some post editor screen in wp-admin to look up an address that has not been used on your site yet. For example, a random museum in St. Augustine FL at 75 King St, St. Augustine, FL 32084

If any server-side errors occur during the caching process, this will create an error_log.txt file in your site's root directory. Please download that file, open it with any text editor, and copy + paste the contents of that file into your next reply. Once that is done, you can revert the changes you made to wp-config.php and delete the log file.

Let me know what you find out, or if there is no log file created, and I can take a closer look.

#1560467

I found a problem right away. When I clicked 'check api' it gave me:
REQUEST_DENIED - API keys with referer restrictions cannot be used with this API.
Which is odd, seeing as I'm getting good responses for the address lookups that are happening.
Also, I'm not sure why this would affect the caching.
Let me tweak it in Google and see what I get...
OK Giving it time to settle that error has now gone. However, I've just tried a maps address look up and there is still nothing in the cache using 'Load Stored Data' (after a page refresh).

What API restrictions should I set in the Google Cloud Console? I started by using IP address, but I think that was problematic, then switched to referrer restriction.

I just set wp_debug to false and added the other extra lines. No change of behaviour on the site. But this is the log:
[23-Mar-2020 17:14:01 UTC] WordPress database error FUNCTION chardcovhelp.ST_X does not exist for query SELECT address_passed, ST_X(point) as lon, ST_Y(point) as lat FROM wp_toolset_maps_address_cache made by do_action('wp_ajax_wpv_addon_maps_get_stored_data'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, Toolset_Addon_Maps_Views->get_stored_data, Toolset_Addon_Maps_Common::get_cached_coordinates, Toolset_Addon_Maps_Common::load_cached_coordinates

BTW, another support guy 'Nigel' has a full copy of the site that he is working on for another support ticket - if you need to use it.

#1561367

I'm noticing pairs of error log lines like this:

[24-Mar-2020 10:31:22 UTC] WordPress database error FUNCTION chardcovhelp.ST_X does not exist for query SELECT address_passed, ST_X(point) as lon, ST_Y(point) as lat FROM wp_toolset_maps_address_cache made by edit_post, wp_update_post, wp_insert_post, do_action('save_post'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, wpcf_admin_save_post_hook, wpcf_admin_post_save_post_hook, WPCF_Field->save, add_post_meta, add_metadata, do_action('added_post_meta'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, Toolset_Addon_Maps_Types->save_field_coordinates, Toolset_Addon_Maps_Common::get_coordinates, Toolset_Addon_Maps_Common::get_coordinates_new, Toolset_Addon_Maps_Common::get_cached_coordinates, Toolset_Addon_Maps_Common::load_cached_coordinates
[24-Mar-2020 10:31:22 UTC] WordPress database error FUNCTION chardcovhelp.ST_PointFromText does not exist for query INSERT INTO wp_toolset_maps_address_cache ( `address_passed`, `address`, `point` ) VALUES ( '3 Vicarage Close, Chard, UK', '3 Vicarage Cl, Chard TA20 2HH, UK', ST_PointFromText('POINT(-2.962435 50.868370)') ) made by edit_post, wp_update_post, wp_insert_post, do_action('save_post'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, wpcf_admin_save_post_hook, wpcf_admin_post_save_post_hook, WPCF_Field->save, add_post_meta, add_metadata, do_action('added_post_meta'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, Toolset_Addon_Maps_Types->save_field_coordinates, Toolset_Addon_Maps_Common::get_coordinates, Toolset_Addon_Maps_Common::get_coordinates_new, Toolset_Addon_Maps_Common::update_cached_coordinates

So I can see that the second log entry means that the SQL INSERT fails because it is missing data.

#1561841

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I'm noticing pairs of error log lines like this:
It seems your server is running MySQL 5.5.62, which is a bit out of date. Toolset's minimum requirement is 5.6: https://toolset.com/toolset-requirements/

So that would explain why caching isn't happening, the database engine is a bit outdated. Is it possible to get your host to update MySQL, or run on a server with a more modern MySQL version?

#1562687

I've just run a dev copy on a new server and it fixes my other (big) problem. Initially I'm not seeing any maps caching though.

I'll get back to you once I've moved the live site to the new server in an hours time.

#1562971

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I'll stand by for your update.

#1565781

Hi,
The move to a server with a higher MySQL (and PHP) version fixed the problem. I can now see a list of cached locations.
Thanks for your help.
Mark