Bug in WPMUDEV Google Maps Plugin

There is a bug in maps plugin, that leads to empty edit screen:

http://www.awesomescreenshot.com/image/313665/ca4253a5f56fd1b9e94ce04036cd39c5

Due to JS error:

http://www.awesomescreenshot.com/image/313670/224773ae369490c245c38013c886e420

Reason:

When you click on “Preview/edit”

http://www.awesomescreenshot.com/image/313673/3dd117b9e77aceb6e1a9e6064e70ba42

It makes AJAX request to get_map() function in wpmu_dev_maps_plugin/inc/class-agm-map-model.php on line 549

Where it will first try to get map from cache:

$map = wp_cache_get( $id, ‘agm_map’ );

And if cache is empty, it will recreate the map object and store it in cache using :

$map = $this->prepare_map( $map );

But the same cache object is also created in another function save_map() (same file, line 603), but there is used another function:

$data = $this->prepare_for_save( $map );

But in prepare_for_save() there is ‘defaults’ attribute missing from $map_options, which leads to empty data.defaults in AJAX response and that JS error correspondingly.

So once it was saved using “Save Changes” button, map can’t be viewed again (until map object cache expires). Bug confirmed on all AF sites (where WP Object Cache enabled)

Solution:

E.g. in save_map() function on line 626 add:

$defaults = $this->get_map_defaults();

$map = $defaults;

before

wp_cache_set( $ret, $map, ‘agm_map’ );