feat(2meet-data-optimizer): store post_status and post_date copies in post entity tables
- TMDO_Post_Status_Sync: post group tables get post_status / post_date
columns (posts' collation) and an (post_status, post_date) index.
Brand-new empty tables get them on creation; existing tables only via
`wp tmdo post-status-sync [--dry-run] [--batch]`, never as DDL on a
populated table in a web request. Per-group state in
tmdo_post_status_columns ('columns' | 'ready').
- transition_post_status refreshes the copies; Hook Bus upserts that
create a post row fill them in (existing rows keep theirs).
- Bench (1M rows): add columns 0.05 s, index 5.3 s, batched backfill 32 s,
0 mismatches afterwards.
- Verify: core unit 659 / integration 466 green, phpcs clean
- PR: PR-028
This commit is contained in:
@@ -328,15 +328,20 @@ final class TMDO_Hook_Bus {
|
||||
|
||||
try {
|
||||
// 單一 upsert,避免 SELECT→UPDATE/INSERT 的 read-modify-write race。
|
||||
// post:新列一併帶入 post_status / post_date 副本(只在 insert 時寫入)。
|
||||
$extra = 'post' === $type ? TMDO_Post_Status_Sync::insert_columns( $entity_id, $group ) : array();
|
||||
$result = TMDO_DB::upsert(
|
||||
$table,
|
||||
array(
|
||||
$id_col => $entity_id,
|
||||
$col => $db_value,
|
||||
array_merge(
|
||||
array(
|
||||
$id_col => $entity_id,
|
||||
$col => $db_value,
|
||||
),
|
||||
$extra
|
||||
),
|
||||
array( $col ),
|
||||
$id_col,
|
||||
array( '%d', $format )
|
||||
array_merge( array( '%d', $format ), array_fill( 0, count( $extra ), '%s' ) )
|
||||
);
|
||||
|
||||
// 清除快取
|
||||
|
||||
Reference in New Issue
Block a user