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
60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Migration phase: demote entity mode from aeav_only back to dual_write.
|
|
*
|
|
* @package TMDO
|
|
* @since 3.0.1
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Two-step mode demotion: aeav_only → shadow_read → dual_write.
|
|
*/
|
|
class TMDO_Phase_Demote extends TMDO_Migration_Phase_Base {
|
|
|
|
/**
|
|
* Returns the phase slug.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function name(): string {
|
|
return 'demote';
|
|
}
|
|
|
|
/**
|
|
* 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_AEAV_ONLY !== $current ) {
|
|
$this->log( $job, "↪ Demote skipped (mode is {$current}, not aeav_only)" );
|
|
return array( 'status' => 'ok' );
|
|
}
|
|
|
|
// Two-step demotion: aeav_only → shadow_read → dual_write.
|
|
$r = TMDO_Mode_Manager::set( $this->entity_type, TMDO_Mode_Manager::MODE_SHADOW_READ );
|
|
if ( is_wp_error( $r ) ) {
|
|
throw new \RuntimeException( 'Demote step 1 failed: ' . $r->get_error_message() );
|
|
}
|
|
|
|
$r = TMDO_Mode_Manager::set( $this->entity_type, TMDO_Mode_Manager::MODE_DUAL_WRITE );
|
|
if ( is_wp_error( $r ) ) {
|
|
throw new \RuntimeException( 'Demote step 2 failed: ' . $r->get_error_message() );
|
|
}
|
|
|
|
$this->log( $job, 'Mode: aeav_only → dual_write (reads now go to EAV)' );
|
|
return array( 'status' => 'ok' );
|
|
}
|
|
}
|