Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export & Import #655

Merged
merged 119 commits into from
Jul 14, 2024
Merged

Export & Import #655

merged 119 commits into from
Jul 14, 2024

Conversation

carstingaxion
Copy link
Collaborator

@carstingaxion carstingaxion commented May 4, 2024

Description of the Change

Closes #650

How to test the Change

Changelog Entry

Added - Export & Import events and venues using the native export & import tools of WordPress

Credits

Props @carstingaxion

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

wtd:summary

Copy link

what-the-diff bot commented May 4, 2024

PR Summary

  • Introduced a new Class for exporting content
    A new Export class has been added which will handle the exporting of content using WordPress' native export tool. This class will enhance overall content management, provide effective filtering, and support validation of the objects based on their post type and meta key.

  • Establishment of a Migration Trait
    In addition to the Export class, a new Migrate trait was introduced. This trait is closely related to the import and export of content. The core function, named pseudopostmetas, returns an array of pseudo-post-metas which will be of significant help in the export-import processes.

@carstingaxion
Copy link
Collaborator Author

carstingaxion commented May 7, 2024

Dear @mauteri ,

while this is still not ready, needs a lot of docs, etc. I would like to have your feedback on the initial direction. Could you take a look at the code I have here so far? This would be nice!

@mauteri
Copy link
Contributor

mauteri commented May 7, 2024

Dear @mauteri ,

while this is still not ready, needs a lot of docs, etc. I would like to have your feedback on the initial direction. Could you take a look at the code I have here so far? This would be nice!

Sure, I can start testing this. My time schedule has been a bit crazy lately, but I'll look to carve out time soon to test this. Thanks!

includes/core/classes/class-import.php Outdated Show resolved Hide resolved
includes/core/classes/class-import.php Outdated Show resolved Hide resolved
includes/core/classes/class-export.php Outdated Show resolved Hide resolved
@mauteri
Copy link
Contributor

mauteri commented May 8, 2024

@carstingaxion I tried exporting and importing, but the datetime start and end data was not imported. Maybe we should screenshare on this one when you have some time so you can take me through this. thx!

@stephenerdelyi
Copy link
Collaborator

This is working for me, though I'm not 100% sure why - I can't seem to find where the export is storing the event date?

Otherwise - all meta is storing as expected:

  • Title
  • Description
  • Post content (date, RSVP status, venue*)

The only other issue I noticed (which I'm not sure we can get around) is that when you import both venues and events, it can't retain the link an event has to a venue, since the IDs have changed.

@mauteri
Copy link
Contributor

mauteri commented May 12, 2024

The only other issue I noticed (which I'm not sure we can get around) is that when you import both venues and events, it can't retain the link an event has to a venue, since the IDs have changed.

IDs shouldn't matter as the CPT and taxonomy term are tied by slug which won't change. Also the binding of Event to Venue is just a normal taxonomy term, nothing fancy. I'll have to test this again.

@carstingaxion
Copy link
Collaborator Author

carstingaxion commented May 14, 2024

Thanks for trying and testing @stephenerdelyi and @mauteri !!

I made a short screencast to show the walk-through (for you, me and all others)

Bildschirmaufzeichnung.vom.14.05.2024.13.19.29.mp4

I took that date, because I read somewhere in a slack-channel that it is a kind of special holiday in New York. 🥳 🎈

@carstingaxion
Copy link
Collaborator Author

I can't seem to find where the export is storing the event date

Have a look at the exported .xml file @stephenerdelyi , there should be a section at the end of the postmeta data, that looks like this and contains all data:

<wp:postmeta>
	<wp:meta_key><![CDATA[gatherpress_datetimes]]></wp:meta_key>
	<wp:meta_value><![CDATA[a:5:{s:14:"datetime_start";s:19:"2024-05-11 18:00:00";s:18:"datetime_start_gmt";s:19:"2024-05-11 22:00:00";s:12:"datetime_end";s:19:"2024-05-11 20:00:00";s:16:"datetime_end_gmt";s:19:"2024-05-12 00:00:00";s:8:"timezone";s:16:"America/New_York";}]]></wp:meta_value>
</wp:postmeta>

@carstingaxion carstingaxion marked this pull request as ready for review May 31, 2024 17:09
includes/core/classes/class-export.php Outdated Show resolved Hide resolved
includes/core/classes/class-export.php Outdated Show resolved Hide resolved
includes/core/classes/class-export.php Outdated Show resolved Hide resolved
includes/core/classes/class-export.php Show resolved Hide resolved
includes/core/classes/class-export.php Outdated Show resolved Hide resolved
includes/core/classes/class-export.php Outdated Show resolved Hide resolved
includes/core/classes/class-import.php Outdated Show resolved Hide resolved
*/
add_filter( 'wp_import_post_data_raw', array( '\GatherPress\Core\Import', 'set_entry_point' ) );
}
add_action( 'gatherpress_import', array( '\GatherPress\Core\Import', 'import' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, just call Import after including use

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I understood what you meant, but went with self::class, because I'm referencing only static functions.
But I'm still not sure, about it.

Will this work and be ok?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please have a Quick Look at this Long open review comment @mauteri ?

includes/core/classes/class-import.php Outdated Show resolved Hide resolved
includes/core/classes/class-import.php Outdated Show resolved Hide resolved
@carstingaxion
Copy link
Collaborator Author

Even all checks pass now, we still have:

[15-Jun-2024 13:26:31 UTC] WordPress database error Table 'wordpress.wp_pc_gatherpress_events' doesn't exist for query DELETE FROM `wp_pc_gatherpress_events` WHERE `post_id` = 7 made by include('phar:///usr/local/bin/wp/php/boot-phar.php'), include('phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->run_command_and_exit, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}, call_user_func, WordPress\Plugin_Check\CLI\Plugin_Check_Command->check, WordPress\Plugin_Check\Checker\Abstract_Check_Runner->run, WordPress\Plugin_Check\Checker\Preparations\Demo_Posts_Creation_Preparation->WordPress\Plugin_Check\Checker\Preparations\{closure}, wp_delete_post, do_action('delete_post'), WP_Hook->do_action, WP_Hook->apply_filters, GatherPress\Core\Event_Setup->delete_event

@carstingaxion
Copy link
Collaborator Author

Technically finished @mauteri .

Nice to have, still remain:

  • Documentation
  • Unit tests

@MervinHernandez
Copy link
Collaborator

✅ Tests = PASS July 13

  • ✅ Part 1 = Confirm issue
    1. ✅ EXPORT Events out of [gatherpress.org](http://gatherpress.org/) using WordPress Tools > Export
    2. ✅ CONFIRM No dates visible (for events) in the XML
    3. ✅ IMPORT into Playground (running latest Gatherpress plugin
    4. ✅ CONFIRM Issue = no dates were imported
  • ✅ Part 2 = TEST PR from Carsten Export & Import #655
    1. ✅ CHECKOUT his branch

    2. ✅ CREATE Sample event on a blank site

    3. ✅ EXPORT events outs of this sample site

    4. ✅ VIEW Event meta is in the exported xml

    5. ✅ DELETE Sample event

    6. ✅ IMPORT events (xml just exported)

    7. ✅ VIEW Event = ✅ PASS The event start-end date was correctly imported


@carstingaxion @mauteri practical tests look good. Recommend merging or more advanced testing if needed.

@mauteri
Copy link
Contributor

mauteri commented Jul 14, 2024

@carstingaxion @MervinHernandez I made some small changes to the code to make it look more like the rest of the code in the plugin (removal of static methods). I think this is good to go. I just did an export/import test and it worked great. We should continue to test as we work on the next release. Thanks!

@mauteri mauteri merged commit b58db40 into GatherPress:main Jul 14, 2024
11 checks passed
@carstingaxion carstingaxion deleted the feature/export-import branch August 13, 2024 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export / Import of events does not recognise date & time
7 participants