DiscipleTools / DiscipleTools/disciple-tools-migration

Activity export and import

Open
#21 0 comments 0 reactions 1 assignee Claimed by @kodinkat View on GitHub
Dominant language
PHP
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Description

The activity log table (wp_dt_activity_log) carries everything needed — hist_time, user_id, action, object_type, object_id, object_subtype, object_name, meta_id, meta_key, meta_value, old_value, field_type. The plugin currently exports/imports none of it, so what you see is purely the side-effect rows
generated as the importer makes wp_insert_post / update_post calls.

To make activity behave like comments, the symmetric fix is identical in shape to what we just did for post_user_meta:

1. Export — query wp_dt_activity_log WHERE object_type = $post_type AND object_id IN (...batch ids...). Add a top-level activity_log block to the file payload, and an activity_log field to the REST records_batch response.
2. Import — new engine method import_activity_log_for_posts( $rows, $post_ids_in_scope, $post_type ). For each post_id in scope: DELETE FROM wp_dt_activity_log WHERE object_type = $post_type AND object_id IN (...), then insert the export rows with user_id remapped via the user map and histid left to
auto-increment. The DELETE wipes both the import-noise rows that just got created and any prior activity for those IDs — same replace semantics we agreed on for post_user_meta.
3. Wire in both file-mode and API-mode AJAX handlers right next to the existing import_post_user_meta_for_posts calls.

user_caps we can either preserve from export (correct historical view) or recompute from the remapped user's current role. I'd preserve from export — it's a historical record. Same for hist_ip.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.