Skip to content

#21 - D.T Migration Plugin - Activity Export & Import#22

Open
kodinkat wants to merge 4 commits into
DiscipleTools:masterfrom
kodinkat:21-dt-migration-activity-export-and-import
Open

#21 - D.T Migration Plugin - Activity Export & Import#22
kodinkat wants to merge 4 commits into
DiscipleTools:masterfrom
kodinkat:21-dt-migration-activity-export-and-import

Conversation

@kodinkat
Copy link
Copy Markdown
Collaborator


Screenshot 2026-05-11 at 13 47 43 --- Screenshot 2026-05-11 at 14 12 49 --- Screenshot 2026-05-11 at 14 14 26 --- Screenshot 2026-05-11 at 14 14 44 --- Screenshot 2026-05-11 at 14 15 35 --- Screenshot 2026-05-11 at 14 16 14 --- Screenshot 2026-05-11 at 14 18 49 --- Screenshot 2026-05-11 at 14 19 04 --- Screenshot 2026-05-11 at 14 20 02 --- Screenshot 2026-05-11 at 14 22 46

kodinkat and others added 3 commits May 11, 2026 14:25
- Introduced a new setting to include activity logs during export and import operations.
- Updated the admin interface to allow users to enable or disable activity log inclusion.
- Enhanced the import process to handle activity log rows, ensuring they are imported correctly when the setting is enabled.
- Refactored related classes and methods to accommodate the new functionality, including adjustments to the REST API responses to include activity log counts.
- Updated version number to 1.1 to reflect the addition of this feature.
@corsacca
Copy link
Copy Markdown
Member

@kodinkat

image Default: yes

The created at on is wrong:

image

AI Review:

  1. hist_ip falsely defaults to 127.0.0.1 — non-blocking but wrong

includes/class-dt-migration-export-file.php:410 and class-dt-migration-import-engine.php:529:
'hist_ip' => isset( $row['hist_ip'] ) ? (string) $row['hist_ip'] : '127.0.0.1',
Falsifying a historical IP is a bad default. '' or null (if the column is nullable) would be more
honest. Same nit for 'user_caps' ?? 'guest'.

  1. Per-row $wpdb->insert() will be slow on large activity logs

class-dt-migration-import-engine.php:519 inserts one row at a time. The DT activity log can easily
have 10–100× the row count of records. On a 50k-record site, this could mean hundreds of thousands
of single-row inserts per batch. The existing import_post_user_meta_for_posts does the same — so
this PR isn't a regression — but it's the most likely perf cliff users will hit with the flag on.
Consider a multi-row INSERT (chunked, e.g., 500 rows/statement) as a follow-up. Worth at least a
comment.

Minor

  1. Loop body in class-dt-migration-tab-import.php:196-199 does a count it doesn't use

$activity_n = 0;
if ( $this->import_preview_export_include_activity_log && isset( $activity_raw[ $post_type ] ) &&
is_array( $activity_raw[ $post_type ] ) ) {
$activity_n = count( $activity_raw[ $post_type ] );
}
$row = [ 'count' => is_array( $recs ) ? count( $recs ) : 0 ];
if ( $this->import_preview_export_include_activity_log ) {
$row['activity_log_count'] = $activity_n;
}
When import_preview_export_include_activity_log is false, $activity_n is computed (well, stays 0)
but never used. Reorder so the count() only runs inside the outer guard — small thing.

…logic

- Updated the default setting for including activity logs in migration settings to true.
- Refactored the import logic to ensure accurate counting of activity logs during the import process.
- Enhanced the handling of user capabilities and IP addresses in the migration export process for improved data integrity.
- Introduced a new method to build post date fields from exported records, supporting various date formats.
- Added unit tests for the new date handling functionality to ensure reliability.
@kodinkat
Copy link
Copy Markdown
Collaborator Author

@corsacca review ready....

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.

Activity export and import

2 participants