From 8f1bbe535a8baede9dd94f5d29593a05ef2cc446 Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Tue, 3 Feb 2026 17:39:47 +0100 Subject: [PATCH 1/3] fix: no table ready while installing During WordPress installation, database operations are deferred by the Schema library's Builder::up() method. This fix ensures the shepherd_{prefix}_tables_registered action is not fired when wp_installing() returns true, preventing downstream code from attempting to use tables that don't exist yet. --- src/Tables/Provider.php | 8 ++++++++ 1 file changed, 8 insertions(+) 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. * From a628817274535d73c762adea09c93d4483c26b5d Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Tue, 3 Feb 2026 17:48:43 +0100 Subject: [PATCH 2/3] test: add coverage for wp_installing bail --- tests/wpunit/Tables/Tables_Provider_Test.php | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 */ From c234792a1b5e383c0b0bf3249bfa317cc24861c1 Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Tue, 3 Feb 2026 17:53:18 +0100 Subject: [PATCH 3/3] doc: update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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.