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:
@@ -111,6 +111,19 @@ class InstallerV2Test extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public function test_install_does_not_enable_entity_bridge(): void {
|
||||
delete_option( 'wpdo_hook_bus_enabled' );
|
||||
delete_option( 'wpdo_bridge_modes' );
|
||||
delete_option( 'wpdo_entity_bridge_autoactivated_v2' );
|
||||
// Skip the crypto step: it queries $wpdb->options, which InstallerCleanupTest leaves pointing at its own prefix.
|
||||
update_option( 'wpdo_crypto_migrated_v2', '1' );
|
||||
|
||||
TMDO_Installer::install();
|
||||
|
||||
$this->assertFalse( get_option( 'wpdo_hook_bus_enabled' ), 'install() must not switch the Hook Bus on' );
|
||||
$this->assertFalse( get_option( 'wpdo_bridge_modes' ), 'install() must not write bridge modes' );
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass(): void {
|
||||
// Leave v2 tables in place for subsequent tests / dev convenience.
|
||||
// Cleanup happens via wp wpdo cleanup-uae-tables --confirm in real upgrades.
|
||||
|
||||
@@ -302,6 +302,7 @@ if ( ! function_exists( 'wp_strip_all_tags' ) ) { function wp_strip_all_tags( st
|
||||
if ( ! function_exists( 'get_option' ) ) { function get_option( string $key, $default = false ) { return $GLOBALS['_wp_options'][ $key ] ?? $default; } }
|
||||
if ( ! function_exists( 'update_option' ) ) { function update_option( string $key, $value ): bool { $GLOBALS['_wp_options'][ $key ] = $value; return true; } }
|
||||
if ( ! function_exists( 'delete_option' ) ) { function delete_option( string $key ): bool { unset( $GLOBALS['_wp_options'][ $key ] ); return true; } }
|
||||
if ( ! function_exists( 'add_option' ) ) { function add_option( string $key, $value = '', $deprecated = '', $autoload = null ): bool { if ( array_key_exists( $key, $GLOBALS['_wp_options'] ?? array() ) ) { return false; } $GLOBALS['_wp_options'][ $key ] = $value; return true; } }
|
||||
if ( ! function_exists( 'get_transient' ) ) { function get_transient( string $key ) { return $GLOBALS['_wp_transients'][ $key ] ?? false; } }
|
||||
if ( ! function_exists( 'set_transient' ) ) { function set_transient( string $key, $value, int $exp = 0 ): bool { $GLOBALS['_wp_transients'][ $key ] = $value; return true; } }
|
||||
if ( ! function_exists( 'delete_transient' ) ) { function delete_transient( string $key ): bool { unset( $GLOBALS['_wp_transients'][ $key ] ); return true; } }
|
||||
|
||||
@@ -18,9 +18,9 @@ class HookBusBridgeTest extends TestCase {
|
||||
|
||||
// ── is_enabled() ────────────────────────────────────────────────────────
|
||||
|
||||
public function test_is_enabled_default_true(): void {
|
||||
// v2.5.4: Hook Bus is ON by default; option not set → true.
|
||||
$this->assertTrue( WPDO_Hook_Bus_Bridge::is_enabled() );
|
||||
public function test_is_enabled_default_false(): void {
|
||||
// Hook Bus is opt-in; option not set → false. Existing sites store '1' explicitly.
|
||||
$this->assertFalse( WPDO_Hook_Bus_Bridge::is_enabled() );
|
||||
}
|
||||
|
||||
public function test_is_enabled_when_option_set_to_string_one(): void {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Unit test: TMDO_Mode_Manager defaults.
|
||||
*
|
||||
* A fresh install must not route any entity through the flat tables until an
|
||||
* admin opts in; stored modes (e.g. aeav_only on live sites) must be kept as-is.
|
||||
*/
|
||||
class ModeManagerDefaultsTest extends TestCase {
|
||||
|
||||
protected function setUp(): void {
|
||||
$GLOBALS['_wp_options'] = array();
|
||||
TMDO_Mode_Manager::reset_cache();
|
||||
}
|
||||
|
||||
protected function tearDown(): void {
|
||||
TMDO_Mode_Manager::reset_cache();
|
||||
}
|
||||
|
||||
public function test_all_entities_default_to_disabled(): void {
|
||||
$this->assertSame(
|
||||
array(
|
||||
'post' => TMDO_Mode_Manager::MODE_DISABLED,
|
||||
'user' => TMDO_Mode_Manager::MODE_DISABLED,
|
||||
'term' => TMDO_Mode_Manager::MODE_DISABLED,
|
||||
'comment' => TMDO_Mode_Manager::MODE_DISABLED,
|
||||
),
|
||||
TMDO_Mode_Manager::all()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_stored_modes_are_kept(): void {
|
||||
update_option(
|
||||
'wpdo_bridge_modes',
|
||||
array(
|
||||
'post' => 'aeav_only',
|
||||
'user' => 'dual_write',
|
||||
)
|
||||
);
|
||||
|
||||
$modes = TMDO_Mode_Manager::all();
|
||||
|
||||
$this->assertSame( 'aeav_only', $modes['post'] );
|
||||
$this->assertSame( 'dual_write', $modes['user'] );
|
||||
$this->assertSame( TMDO_Mode_Manager::MODE_DISABLED, $modes['term'] );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user