Skip to content

Commit 5f41950

Browse files
committed
Properly cache each implementation's schema
1 parent d5a7d61 commit 5f41950

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
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+
## [3.1.3] 2025-10-08
6+
7+
* Fix - Fix the `get_current_schema` method to cache the schema of each implementation.
8+
9+
[3.1.3]: https://github.com/stellarwp/schema/releases/tag/3.1.3
10+
511
## [3.1.2] 2025-10-02
612

713
* Fix - Fix the `update_many` method to properly check if the transaction was successful.

src/Schema/Tables/Contracts/Table.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ public static function get_searchable_columns(): Column_Collection {
157157
* @throws RuntimeException If the current schema version is not found in the schema history.
158158
*/
159159
public static function get_current_schema(): Table_Schema_Interface {
160-
static $current_schema = null;
160+
static $current_schema = [];
161161

162-
if ( null !== $current_schema ) {
163-
return $current_schema;
162+
if ( ! empty( $current_schema[ static::class ] ) ) {
163+
return $current_schema[ static::class ];
164164
}
165165

166166
$history = static::get_schema_history();
@@ -169,9 +169,9 @@ public static function get_current_schema(): Table_Schema_Interface {
169169
throw new RuntimeException( 'The current schema version is not found in the schema history.' );
170170
}
171171

172-
$current_schema = $history[ static::SCHEMA_VERSION ]();
172+
$current_schema[ static::class ] = $history[ static::SCHEMA_VERSION ]();
173173

174-
return $current_schema;
174+
return $current_schema[ static::class ];
175175
}
176176

177177
/**

0 commit comments

Comments
 (0)