Skip to content

Activity export and import #21

@corsacca

Description

@corsacca

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions