Import creates blank database references with shared IDs

Home Forums Calendar Products Events Calendar PRO Import creates blank database references with shared IDs

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #935663
    joelgoodman
    Participant

    I did a standard events export (using the WP export tool) from a client’s TEC Pro and imported it (using the WP import tool) into a new target site. After importing, I’ve got duplicate references to events, all sharing the same ID, and all displaying on the front end and in the admin.

    Wiped the import, re-imported… same thing.

    Example gif: http://d.pr/i/1chZk/2wh1cW8j

    #935825
    Barry
    Member

    Hi joelgoodman,

    Can you confirm if the problem only impacted recurring events – or were all events impacted?

    Are there any other patterns that jump out at you?

    #935836
    joelgoodman
    Participant

    These are non-recurring events it’s affected.

    #935896
    Barry
    Member

    OK – so in the screen capture it looks like one of the columns next to the events in question contains “Yes” and I took that to be the recurring event column.

    It appeared then that the four events with the same ID were recurring events from the same sequence (I’d therefore expect them to share the same post ID – or, to be specific, the same parent post ID) whereas the other event of the same name but on a different date does not appear to have a “Yes” in that other column and in fact has a different post ID, best I can tell.

    At this stage I’d like to clarify a few things:

    • Are the first four events in your capture definitely not recurring?
    • If those same events aren’t the duplicates, which are?
    • Which version of Events Calendar PRO did you export from?
    • What were the dates of the same sequence of recurring events on the source site (if indeed they were originally recurring)?

    Thanks!

    #935902
    joelgoodman
    Participant

    Alright, so yeah, I see what you’re saying. It seems that, in this case, that particular event became flagged as recurring, somehow, on import.

    Screenshots of the export site/event what it looks like upon import:
    Exported Events Site (3.5.2): http://d.pr/i/sVlj/2opaLcwI
    Imported Events Site (current version): http://d.pr/i/1joJ8/2FeTeDAF

    You can see the date in there… Jan 21 – Jan 21.

    #935940
    Barry
    Member

    Very strange.

    Can you upload a copy of the WordPress export file somewhere and link to it here (from a private reply if you prefer) so I can take a look and even see if I can replicate this?

    #935960
    joelgoodman
    Participant

    This reply is private.

    #936258
    Barry
    Member

    Appreciated!

    Bear with us a little longer while we investigate.

    #936317
    Barry
    Member

    Thanks for your patience, Joel.

    So this is something of an unusual problem and actually we previously added some tweaks to our codebase to try and avoid this sort of problem … unfortunately it seems not to roll into action in some situations – I’ll be sure to report that and we’ll try and make a fix available as soon as we can.

    To give some background, when the WordPress importer runs it tries to avoid creating duplicate posts. It doesn’t test against the post ID, however, but instead compares the post name, date and type of each imported post – if all three are identical to a post that has already been imported, it assumes that is the post we’re interested in.

    My theory is that on the source site you had one or more events which were originally recurring in nature – but were then split apart into standalone events … this would create exactly that sort of condition (where the post name, date and type are identical).

    A side effect is that we can then have one event with multiple start dates – causing Events Calendar PRO to view it as a recurring event (for legacy/backwards compatibility reasons).

    What can you do to fix it?

    Manually correcting this could be pretty onerous if you have many cases of this problem throughout your database, but it’s a possibility.

    Alternatively, if you can roll back and remove all of the events that have already been imported and start again it might avoid this problem so long as you add the following snippet to your theme’s functions.php file before re-importing your data:

    add_filter( 'wp_import_post_data_raw', 'alt_filter_wp_import_data_before', 20 );
    
    function alt_filter_wp_import_data_before( $post ) {
    	if ( $post['post_type'] == TribeEvents::POSTTYPE && 0 == $post['post_parent'] ) {
    		$start_date = '';
    		if ( isset( $post['postmeta'] ) && is_array( $post['postmeta'] ) ) {
    			foreach ( $post['postmeta'] as $meta ) {
    				if ( $meta['key'] == '_EventStartDate' ) {
    					$start_date = $meta['value'];
    					break;
    				}
    			}
    		}
    		if ( ! empty( $start_date ) ) {
    			$post['post_title'] .= '[tribe_start_date]' . $start_date . '[/tribe_start_date]';
    		}
    	}
    
    	return $post;
    }

    Would it be viable to give that a go?

    #936318
    joelgoodman
    Participant

    Yep. I’m in the middle of a user migration, but will try it out as soon as I’m done with that.

    #936319
    Barry
    Member

    Awesome 🙂

    #936346
    joelgoodman
    Participant

    Seems to have worked on my dev instance! I’ll do the import on staging to make sure, but it’s looking good.

    #936401
    Barry
    Member

    Glad to hear it – I’ll wait out here before closing the topic in case you do hit further difficulties, but assuming it goes to plan we’ll look at making the necessary changes in one of our upcoming releases, too.

    Thanks for your support here 🙂

    #936402
    joelgoodman
    Participant

    All good. Everything seems to be in order. Thanks for your help.

    #936494
    Barry
    Member

    Great – thanks for the update 🙂

    I’ll go ahead and close out this thread and we’ll make a change to the plugin as soon as we practically can in an upcoming release.

    Thanks again for working through this one with us and I’ll now close this topic (please do feel free, of course, to create new topics as needed should anything else crop up).

Viewing 15 posts - 1 through 15 (of 17 total)
  • The topic ‘Import creates blank database references with shared IDs’ is closed to new replies.