76c01e44df
對齊 A v3.2.0。型別強制會把隱式轉換變成 TypeError,所以一次全檔加入 並跑完整測試(unit 451 / integration 398 全綠,無迴歸)。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Migration phase: promote entity mode to shadow_read.
|
|
*
|
|
* @package TMDO
|
|
* @since 3.0.1
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Transitions mode from dual_write → shadow_read (flat table serves reads).
|
|
*/
|
|
class TMDO_Phase_Promote_Shadow extends TMDO_Migration_Phase_Base {
|
|
|
|
/**
|
|
* Returns the phase slug.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function name(): string {
|
|
return 'promote_shadow';
|
|
}
|
|
|
|
/**
|
|
* Executes the phase.
|
|
*
|
|
* @param array $job Job array (by reference).
|
|
* @return array{status: string}
|
|
* @throws \RuntimeException If mode transition fails.
|
|
*/
|
|
public function execute( array &$job ): array {
|
|
$current = TMDO_Mode_Manager::get( $this->entity_type );
|
|
|
|
if ( TMDO_Mode_Manager::MODE_DUAL_WRITE === $current ) {
|
|
$r = TMDO_Mode_Manager::set( $this->entity_type, TMDO_Mode_Manager::MODE_SHADOW_READ );
|
|
if ( is_wp_error( $r ) ) {
|
|
throw new \RuntimeException( 'Promote to shadow_read failed: ' . $r->get_error_message() );
|
|
}
|
|
$this->log( $job, 'Mode: dual_write → shadow_read (verifying flat reads)' );
|
|
} else {
|
|
$this->log( $job, "↪ Already at {$current}; skip promote_shadow" );
|
|
}
|
|
|
|
return array( 'status' => 'ok' );
|
|
}
|
|
}
|