private static function handle_geocache_replace($c)
 {
     # Check if any relevant geocache attributes have changed.
     # We will pick up "our" copy of the cache from zero-zoom level.
     try {
         $cache = OkapiServiceRunner::call("services/caches/geocache", new OkapiInternalRequest(new OkapiInternalConsumer(), null, array('cache_code' => $c['object_key']['code'], 'fields' => 'internal_id|code|name|location|type|status|rating|recommendations|founds|trackables_count')));
     } catch (InvalidParam $e) {
         # Unprobable, but possible. Ignore changelog entry.
         return;
     }
     # Fetch our copy of the cache.
     $ours = mysql_fetch_row(Db::query("\n            select cache_id, z21x, z21y, status, type, rating, flags, name_crc\n            from okapi_tile_caches\n            where\n                z=0\n                and cache_id = '" . mysql_real_escape_string($cache['internal_id']) . "'\n        "));
     # Caches near the poles caused our computations to break here. We will
     # ignore such caches!
     list($lat, $lon) = explode("|", $cache['location']);
     if (floatval($lat) >= 89.98999999999999 || floatval($lat) <= -89.98999999999999) {
         if ($ours) {
             self::remove_geocache_from_cached_tiles($ours[0]);
         }
         return;
     }
     # Compute the new row for okapi_tile_caches. Compare with the old one.
     $theirs = TileTree::generate_short_row($cache);
     if (!$ours) {
         # Aaah, a new geocache! How nice... ;)
         self::add_geocache_to_cached_tiles($theirs);
     } elseif ($ours[1] != $theirs[1] || $ours[2] != $theirs[2]) {
         # Location changed.
         self::remove_geocache_from_cached_tiles($ours[0]);
         self::add_geocache_to_cached_tiles($theirs);
     } elseif ($ours != $theirs) {
         self::update_geocache_attributes_in_cached_tiles($theirs);
     } else {
         # No need to update anything. This is very common (i.e. when the
         # cache was simply found, not actually changed). Replicate module generates
         # many updates which do not influence our cache.
     }
 }