diff --git a/CHANGELOG.md b/CHANGELOG.md index e7284b3..0527af7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adhere to the [Semantic Versioning](http://semver.org/) standard. +## [0.2.1] 2026-02-03 + +* Fix - Prevent table readiness checks while WordPress is installing. + ## [0.2.0] 2026-01-05 * Version - Update minimum required version of the stellarwp/schema library to v3.2.0. diff --git a/src/Tables/Provider.php b/src/Tables/Provider.php index 7d09d56..1edcec0 100644 --- a/src/Tables/Provider.php +++ b/src/Tables/Provider.php @@ -57,6 +57,14 @@ public function register(): void { Register::table( Task_Logs::class ); } + /* + * During WordPress installation, database operations are deferred. + * Don't signal table readiness until installation is complete. + */ + if ( wp_installing() ) { + return; + } + /** * Fires an action when the Shepherd tables are registered. * diff --git a/tests/wpunit/Tables/Tables_Provider_Test.php b/tests/wpunit/Tables/Tables_Provider_Test.php index 0e4cc2d..6f69820 100644 --- a/tests/wpunit/Tables/Tables_Provider_Test.php +++ b/tests/wpunit/Tables/Tables_Provider_Test.php @@ -30,6 +30,27 @@ public function it_should_fire_tables_registered_action_when_successful(): void $this->assertTrue( $hook_fired, 'The tables_registered action should be fired' ); } + /** + * @test + */ + public function it_should_not_fire_tables_registered_action_when_wp_installing(): void { + // Mock wp_installing() to return true + $this->set_fn_return( 'wp_installing', true ); + + $hook_fired = false; + $prefix = Config::get_hook_prefix(); + + add_action( "shepherd_{$prefix}_tables_registered", function() use ( &$hook_fired ) { + $hook_fired = true; + } ); + + // Re-register to trigger the action + $provider = new Provider( Config::get_container() ); + $provider->register(); + + $this->assertFalse( $hook_fired, 'The tables_registered action should NOT be fired when wp_installing() returns true' ); + } + /** * @test */