fix(2meet-data-optimizer): archive sweep copies each trashed meta row once
- sweep() skips meta rows already in wpdo_archive (NOT EXISTS on original_meta_id): it copied the same trashed meta again every day and wpdo_archive has no unique key (dev20: 300 rows for 150 meta rows) - TMDO_Zone_Archive::remove_duplicates() keeps the first copy per original_meta_id (rows without one are left alone); install() runs it, so `wp tmdo install` cleans existing sites - wpdo_archive gets KEY idx_original_meta for the lookup (new installs; existing sites via `wp tmdo install`). SCHEMA_VERSION is not bumped, so no web request runs dbDelta - Verify: ZoneArchiveIntegrationTest (2 new); dev20 read-only check: 150 of 300 rows would be removed; unit 709, integration 608, phpcs 0, stan OK - PR: PR-136 (manual F-6)
This commit is contained in:
@@ -217,6 +217,15 @@ class TMDO_Installer {
|
||||
// Idempotent — only creates tables that don't already exist.
|
||||
self::install_v2_tables();
|
||||
|
||||
// 1.4.2: archive sweeps before this release copied trashed meta daily.
|
||||
if ( class_exists( 'TMDO_Zone_Archive' ) ) {
|
||||
global $wpdb;
|
||||
$archive = TMDO_Zone_Archive::table();
|
||||
if ( $archive === $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $archive ) ) ) ) {
|
||||
TMDO_Zone_Archive::remove_duplicates();
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'wpdo_db_version', self::SCHEMA_VERSION );
|
||||
|
||||
// Register wpdo_features with autoload=no so it doesn't inflate every page load.
|
||||
@@ -1440,7 +1449,8 @@ class TMDO_Installer {
|
||||
original_meta_id bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_post_id (post_id),
|
||||
KEY idx_post_type_date (post_type, archived_at)
|
||||
KEY idx_post_type_date (post_type, archived_at),
|
||||
KEY idx_original_meta (original_meta_id)
|
||||
) {$charset};";
|
||||
|
||||
foreach ( $sqls as $sql ) {
|
||||
|
||||
Reference in New Issue
Block a user