Facebook events importing duplicates

Home Forums Calendar Products Event Aggregator Facebook events importing duplicates

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1057283
    Caroline Clifford
    Participant

    I’m not sure why this was closed, it’s still very much a problem. I have all the latest versions of all your plugins and I get dozens of duplicates of events. Coudn’t you simply make a patch that doesn’t allow 2 events with the same facebook ID ?

    #1058016
    Brian
    Member

    Hi,

    The issue is not closed, just the topic for new replies.

    There already is a check if an event has the same Facebook ID and that was failing, but we were unable to find out way and could not reproduce the issue until a couple days ago.

    The bug we are seeing is events that ended yesterday are duplicating, but only those events. So for example today is the 18th the importer will still be trying to import events from the 17th and duplicating those over and over. On the 19th it would try to do that with the events on the 18th. Do you find that is where the duplicates are happening?

    I attempting to reproduce the bug, but not able today as I had no events on the 17th and it will not duplicate any of the others.

    I think I will be able to reproduce tomorrow and then be able to create a patch.

    Can you please disable automatic imports for today and I will get back to you tomorrow.

    Thanks

    #1058860
    Brian
    Member

    Hi,

    I believe I have found the issue for the duplicating events and during my tests today I created a patch that worked for me in stopping the duplication of events.

    The events that were duplicating were either past events from one day back or events that ended earlier in the current day. If you are having events duplicate beyond this time frame please let us know as that would be a different bug then this one.

    To patch the issue please replace this file:

    plugins/the-events-calendar-facebook-importer/src/Tribe/Importer.php

    With the contents of this file:

    https://gist.github.com/jesseeproductions/b1180c6366e10875ad80

    I would recommend setting your import status to pending for Facebook just in case the patch does not work.

    Please clear out any existing duplicates after adding the patch to prevent false positives.

    Let me know how that works out.

    Thanks

    #1060836
    Caroline Clifford
    Participant

    Hi sorry for the lateness of my response I never got email notified of the reply. I will try this and let you know – thanks for everything!

    #1060842

    Hello Tribe

    I have encountered the problem as well.

    In a case last year the duplication appeared to happen in the time frame between the beginning af an imported events and the first hour after midnight of the day of the event.
    Initially I reckoned the duplication was due to a missing end time in the facebook event, but that does not seem to be the case, since a recent event had a defined end time and duplicated anyway.
    In this case the duplication actually happened after the end time and the first hour after midnight.

    See the facebook event here:
    https://www.facebook.com/events/1653929681523931/

    See the duplicate WP events here:
    list: http://silkeborghojskole.dk/kalender/liste/?tribe_paged=1&tribe_event_display=past

    original event published January 13, 2016, 14:41:
    http://silkeborghojskole.dk/begivenheder/foredrag-med-forfatter-svend-aage-madsen

    duplicate events:
    Published January 20, 2016, 22:41:
    http://silkeborghojskole.dk/begivenheder/foredrag-med-forfatter-svend-aage-madsen-2
    Published January 20, 2016, 23:50:
    http://silkeborghojskole.dk/begivenheder/foredrag-med-forfatter-svend-aage-madsen-3
    Published January 21, 2016, 00:39:
    http://silkeborghojskole.dk/begivenheder/foredrag-med-forfatter-svend-aage-madsen-4

    Hope you find a solution to the problem since it causes some frustration with the people responsible for the website’s calendar.

    Will the above mentioned patch be included in a future update of the plugin?

    Best Regards

    Kristian Stokholm

    #1061053
    Caroline Clifford
    Participant

    Hey there, I made this bit of PHP to remove duplicate events from my DB & run it with Cron, I know it’s a shitty piece of code but PHP and Mysql aren’t really my thing ! Tested it and it works though…

    
    <?php
    
    $mysql = array(
        "server" => "your",
        "user" => "values",
        "pass" => "in",
        "db" => "here",
        "wp_prefix" => "wp_"
    );
    
    $con = mysql_connect($mysql['server'],$mysql['user'],$mysql['pass']);
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db ($mysql['db'], $con)
        or die ("Unable to select database");
    
    $res = mysql_query("SELECT meta_value, COUNT(*) c FROM " . $mysql['wp_prefix'] . "postmeta WHERE meta_key = '_FacebookID' GROUP BY meta_value HAVING c > 1", $con)
        or die ("Unable to run query");
    
    $nrows = mysql_num_rows($res);
    
    if($nrows == 0) {
        echo "No dupes... Bye!";
        exit;
    }
    
    $ids = [];
    
    while ($row = mysql_fetch_array($res)) {
        array_push($ids, $row['meta_value']);
    }
    
    $count = 0;
    $delete_ids = [];
    foreach ($ids as $id) {
        $res = mysql_query("SELECT post_id FROM " . $mysql['wp_prefix'] . "postmeta WHERE meta_value = '" . $id . "' AND meta_key = '_FacebookID'", $con);
        while ($row = mysql_fetch_array($res)) {
            if($count > 0) {
                array_push($delete_ids, $row['post_id']);
            }
            $count ++;
        }
        $count = 0;
    }
    
    foreach ($delete_ids as $id) {
        $res = mysql_query("DELETE FROM " . $mysql['wp_prefix'] . "postmeta WHERE post_id = '" . $id . "'", $con)
            or die ("Could not delete from postmeta");
        $res = mysql_query("DELETE FROM " . $mysql['wp_prefix'] . "posts WHERE ID = '" . $id . "'", $con)
            or die ("Could not delete from posts");
    }
    
    echo "Deleted: ";
    print_r($delete_ids);
    
    mysql_close($con);
    
    ?>
    
    #1061468
    Brian
    Member

    Hi Caroline,

    Let me know about the patched coding and if that stops the duplicates for you. This patch should be included in the next major release.

    Hi Kristian,

    Thanks for posting here and I think the patch above will fix your issue as well. If it turns out to not be the case, please create your own ticket and we can help you one on one.

    Thanks

    #1069202
    Charles Bartlett
    Participant

    Hi Brian,
    Thanks for posting the patch here and I would like to confirm something about it. There are the following two scenarios for this problem:

    1. Exact duplicate events created of the original on a reoccurring basis. (seems random)

    2. Additional events created (similar to the original) when the event info changes on Facebook.

    Does the patch address #2?

    By accident I discovered scenario #2 and now wondering if that has been happening all along.

    #1069271
    Brian
    Member

    Hi cbzen,

    This is the first I have seen the second issue reported.

    Please create your own thread so we can help out on that issue one on one.

    Thanks

    #1080769
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Facebook events importing duplicates’ is closed to new replies.