Skip to content
Snippets Groups Projects
Commit 377bdc32 authored by Brandon Bergren's avatar Brandon Bergren
Browse files

#350408 by pillarsdotnet: Selecting "Regenerate marker cache" does not...

#350408 by pillarsdotnet: Selecting "Regenerate marker cache" does not reliably clear and rebuild the marker cache.
Changes:
gmap_regenerate_markers()

    * Pass TRUE to the gmap_get_icondata() function
    * Pass TRUE to the gmap_set_marker_titles() function

gmap_set_marker_titles()

    * Simplify and correct the caching logic

gmap_flush_caches()

    * Add an implementation of hook_flush_caches to ensure that clicking on the "Clear cached data" button from the /admin/settings/performance page also rebuilds the marker cache.
parent bb09e0b6
No related branches found
No related tags found
No related merge requests found
......@@ -499,9 +499,19 @@ function gmap_regenerate_markers() {
$contents .= "// GMap marker image data.\n";
$contents .= "Drupal.gmap.iconpath = ". drupal_to_js(base_path() . drupal_get_path('module', 'gmap') .'/markers') .";\n";
$contents .= "Drupal.gmap.icondata = ". drupal_to_js(gmap_get_icondata()) .";\n";
$contents .= "Drupal.gmap.icondata = ". drupal_to_js(gmap_get_icondata(TRUE)) .";\n";
file_save_data($contents, "$jspath/gmap_markers.js", FILE_EXISTS_REPLACE);
// Also regenerate the cached marker titles array
gmap_get_marker_titles(TRUE);
}
/**
* Implementation of hook_flush_caches().
*/
function gmap_flush_caches() {
gmap_regenerate_markers();
}
/**
......@@ -973,19 +983,23 @@ function gmap_get_auto_mapid() {
*/
function gmap_get_marker_titles($reset = FALSE) {
static $titles;
if (is_array($titles) && !$reset) {
return $titles;
}
$titles = cache_get('gmap_marker_titles');
if ($titles) {
$titles = $titles->data;
}
if (!reset) {
if (is_array($titles)) {
return $titles;
}
if ($reset || !$titles) {
require_once(drupal_get_path('module', 'gmap') .'/gmap_markerinfo.inc');
$titles = _gmap_get_marker_titles();
$cached = cache_get('gmap_marker_titles', 'cache');
if (!empty($cached)) {
$titles = $cached->data;
if (is_array($titles)) {
return $titles;
}
}
}
require_once(drupal_get_path('module', 'gmap') .'/gmap_markerinfo.inc');
$titles = _gmap_get_marker_titles();
cache_set('gmap_marker_titles', $titles, 'cache');
return $titles;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment