Home › Forums › Calendar Products › Events Calendar PRO › Import creates blank database references with shared IDs
- This topic has 16 replies, 4 voices, and was last updated 8 years, 7 months ago by Geoff.
-
AuthorPosts
-
January 21, 2015 at 7:55 am #935663joelgoodmanParticipant
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
January 21, 2015 at 12:17 pm #935825BarryMemberHi 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?
January 21, 2015 at 12:37 pm #935836joelgoodmanParticipantThese are non-recurring events it’s affected.
January 21, 2015 at 2:31 pm #935896BarryMemberOK – 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!
January 21, 2015 at 2:42 pm #935902joelgoodmanParticipantAlright, 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/2FeTeDAFYou can see the date in there… Jan 21 – Jan 21.
January 21, 2015 at 3:44 pm #935940BarryMemberVery 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?
January 21, 2015 at 4:32 pm #935960joelgoodmanParticipantThis reply is private.
January 22, 2015 at 9:40 am #936258BarryMemberAppreciated!
Bear with us a little longer while we investigate.
January 22, 2015 at 11:54 am #936317BarryMemberThanks 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?
January 22, 2015 at 11:56 am #936318joelgoodmanParticipantYep. I’m in the middle of a user migration, but will try it out as soon as I’m done with that.
January 22, 2015 at 11:59 am #936319BarryMemberAwesome 🙂
January 22, 2015 at 12:51 pm #936346joelgoodmanParticipantSeems to have worked on my dev instance! I’ll do the import on staging to make sure, but it’s looking good.
January 22, 2015 at 2:33 pm #936401BarryMemberGlad 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 🙂
January 22, 2015 at 2:35 pm #936402joelgoodmanParticipantAll good. Everything seems to be in order. Thanks for your help.
January 22, 2015 at 4:35 pm #936494BarryMemberGreat – 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).
-
AuthorPosts
- The topic ‘Import creates blank database references with shared IDs’ is closed to new replies.