A script to fix Geo Mashup update

On one of my web logs, I use a map to display the route of my travels. Each post is geo-tagged, so places can be connected with lines. It’s a very nice feature for a travel blog, thanks to the Geo Mashup plugin for WordPress. I recently updated the Geo Mashup plugin to a new version. For this version, the locations had to be converted to the new format. The result of this upgrade was that my route was no longer correct: posts seemed randomly connected to each other.

After some investigation, I found that Geo Mashup uses a special table to link posts and location to each other. This link also has a date and time connected to it. The results are ordered using this date. During the conversion, each link had the date of the conversion. Therefore, the results were displayed random.

I wrote a quick PHP script to fix this problem. This script looks at the time the original post was made, and updates the Geo Mashup table.


// CONFIG

// username for the database
$USERNAME = 'username';

// password for the database
$PASSWORD = 'password';

// name of the database containing WordPress
$DATABASE = 'wordpress';

// host for the database (99% chance it will be localhost)
$HOST = 'localhost';

// END OF CONFIG

$link = mysql_connect($HOST,$USERNAME,$PASSWORD) or die('Cannot connect to database '.$HOST);
$x = mysql_select_db($DATABASE,$link) or die('Cannot select database '.$DATABASE);

$result = mysql_query("SELECT * FROM wp_geo_mashup_location_relationships");
while($row = mysql_fetch_assoc($result)
{
$result2 = mysql_query("SELECT post_date FROM wp_posts WHERE id=".$row['object_id']);
mysql_query("UPDATE wp_geo_mashup_location_relationships SET geo_date=\'" . $row2['post_date'] . "\'");
}

After running this script, the problem was fixed, and my map displayed the correct route.

7 thoughts on “A script to fix Geo Mashup update

  1. HI,
    I think I am going to have to move from a host that keeps going down to a new one; I have (so far!) about 1600 posts with Geo Mashup maps. I thinkk I can get through a cpanel/phpmyadmin database export and import, but there are 2 issues; Firstly, do I do that, then install WordPress, or or can I just FTP copy the WP folders?
    Secondly, to quote the plugin author:
    “Geo Mashup does not yet support the WordPress post export and import. We can make this a feature request to track progress on this.
    Your best recovery scenario is if you have a backup of your original database. You would then install Geo Mashup 1.4beta3, check the “Copy Geodata Meta Fields” option and update. View the update log at the bottom of the settings to make sure everything went ok, then do the export and import. This doesn’t preserve your saved location names and related address information, but at least preserves the coordinates for posts so your maps will regenerate on import.” – is there a way to reconnect the coordinates with names?
    Neil

    1. Neil,

      If you are moving hosts, and are not changing the version of WordPress/plugins you use, the best would be to make an export of your current database, then copy all the files from the old host to the new, and then import the database. As long as the URLs do not change, it will not cause too much of a problem.
      The script I mentioned about was because I had a (quite) old version of Geo Mashup, and wanted to move to a new version. Between my old, and the new version, the database model changed. That’s why I needed a script to do some manual updates. But if you’re not changing version, doing a complete manual export/import would be the way to go.

  2. b) We have not, for years, used an email address that
    resembles our actual name. We recommend that you
    try Recovery Toolbox for Zip check integrity file zip,
    this zip file checker easily opens compressed files if their internal structure is corrupted.
    You can bypass the main activation screen and
    you will not need any authentic Apple ID credentials for the sake of starting
    the phone.

    my blog bypass Activation iphone

  3. Hi,
    I’m using Geo Mashup as well, and used some custom scripts to tweak it the way I want on my website, but the last feature I’d like to add would be to draw a route between the posts coordinates that are displayed on the global map. I looked at Geo Mashup doc but can’t find any info about it. How exactly did you set this up?
    Thanks
    Adrien

    1. If all the posts are tagged with a geo-location, just set up a new page and add as content “[geo_mashup_map]”. That should be it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.