Skip to content

Commit f35d201

Browse files
authored
Merge pull request #21 from stellarwp/fix/no-table-ready-while-installing
Fix - no table ready while installing
2 parents 63c02ff + c234792 commit f35d201

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file. This project adhere to the [Semantic Versioning](http://semver.org/) standard.
44

5+
## [0.2.1] 2026-02-03
6+
7+
* Fix - Prevent table readiness checks while WordPress is installing.
8+
59
## [0.2.0] 2026-01-05
610

711
* Version - Update minimum required version of the stellarwp/schema library to v3.2.0.

src/Tables/Provider.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public function register(): void {
5757
Register::table( Task_Logs::class );
5858
}
5959

60+
/*
61+
* During WordPress installation, database operations are deferred.
62+
* Don't signal table readiness until installation is complete.
63+
*/
64+
if ( wp_installing() ) {
65+
return;
66+
}
67+
6068
/**
6169
* Fires an action when the Shepherd tables are registered.
6270
*

tests/wpunit/Tables/Tables_Provider_Test.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,27 @@ public function it_should_fire_tables_registered_action_when_successful(): void
3030
$this->assertTrue( $hook_fired, 'The tables_registered action should be fired' );
3131
}
3232

33+
/**
34+
* @test
35+
*/
36+
public function it_should_not_fire_tables_registered_action_when_wp_installing(): void {
37+
// Mock wp_installing() to return true
38+
$this->set_fn_return( 'wp_installing', true );
39+
40+
$hook_fired = false;
41+
$prefix = Config::get_hook_prefix();
42+
43+
add_action( "shepherd_{$prefix}_tables_registered", function() use ( &$hook_fired ) {
44+
$hook_fired = true;
45+
} );
46+
47+
// Re-register to trigger the action
48+
$provider = new Provider( Config::get_container() );
49+
$provider->register();
50+
51+
$this->assertFalse( $hook_fired, 'The tables_registered action should NOT be fired when wp_installing() returns true' );
52+
}
53+
3354
/**
3455
* @test
3556
*/

0 commit comments

Comments
 (0)