fix(2meet-data-optimizer): stop auto-activating entity bridge on install

- install() no longer switches the Hook Bus on or puts user/term/comment
  into dual_write; the now-unused maybe_autoactivate_entity_bridge() is gone
- Hook Bus and Mode_Manager defaults are off/disabled; sites with stored
  modes (incl. aeav_only) keep them since only unset keys use defaults
- Guard run_dbdelta()'s upgrade.php require like install_v2_tables() so
  install() can run under the integration test stub

Verify: InstallerV2Test::test_install_does_not_enable_entity_bridge,
  ModeManagerDefaultsTest; unit 602 OK, integration 421 OK
PR: PR-007
This commit is contained in:
2026-09-25 21:48:23 +08:00
parent 151aadd661
commit fc0f018a94
7 changed files with 77 additions and 46 deletions
+4 -36
View File
@@ -224,47 +224,12 @@ class TMDO_Installer {
add_option( 'wpdo_features', array(), '', 'no' );
}
// v2.5.4: one-time migration — enable Hook Bus + activate user/term/comment bridge.
self::maybe_autoactivate_entity_bridge();
// v2.15.0: one-time crypto migration — re-encrypt v1 CBC ciphertext as
// v2 GCM. Idempotent best-effort: skipped if no v1 ciphertext present
// or if the migration flag is already set.
self::maybe_migrate_crypto_v1_to_v2();
}
/**
* One-time migration: enable Hook Bus and set user/term/comment to dual_write.
*
* Runs once per site (guarded by wpdo_entity_bridge_autoactivated_v2 flag).
* Safe: dual_write still writes native EAV — zero data-loss risk.
*
* @return void
*/
private static function maybe_autoactivate_entity_bridge(): void {
if ( get_option( 'wpdo_entity_bridge_autoactivated_v2' ) ) {
return;
}
// Enable Hook Bus.
update_option( 'wpdo_hook_bus_enabled', '1', false );
// Upgrade user/term/comment from disabled → dual_write.
$modes = get_option( 'wpdo_bridge_modes', array() );
if ( ! is_array( $modes ) ) {
$modes = array();
}
foreach ( array( 'user', 'term', 'comment' ) as $type ) {
if ( ! isset( $modes[ $type ] ) || 'disabled' === $modes[ $type ] ) {
$modes[ $type ] = 'dual_write';
}
}
// post entity is intentionally left alone — it uses the legacy Feature_Flags FSM.
update_option( 'wpdo_bridge_modes', $modes, false );
update_option( 'wpdo_entity_bridge_autoactivated_v2', '1', false );
}
/**
* One-time best-effort crypto migration v1 (CBC) → v2 (GCM) (v2.15.0).
*
@@ -1303,7 +1268,10 @@ class TMDO_Installer {
*/
private static function run_dbdelta(): void {
global $wpdb;
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
// Same guard as install_v2_tables(): integration tests provide a stub dbDelta().
if ( ! function_exists( 'dbDelta' ) ) {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
}
$charset = $wpdb->get_charset_collate();
$p = $wpdb->prefix;