Skip to content

Commit af1a026

Browse files
authored
Preserve configured SQLite journal mode in driver wrapper
1 parent 2d0dbc0 commit af1a026

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎packages/mysql-on-sqlite/src/sqlite/class-wp-sqlite-driver.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function __construct(
7171
array(
7272
'mysql_version' => $mysql_version,
7373
'pdo' => $connection->get_pdo(),
74+
'journal_mode' => $connection->query( 'PRAGMA journal_mode' )->fetchColumn(),
7475
)
7576
);
7677
$this->main_db_name = $database;

‎packages/mysql-on-sqlite/tests/WP_SQLite_Connection_Tests.php‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ public function testExplicitJournalModeSurfacesFailureWhenWalIsUnavailable(): vo
178178
);
179179
}
180180

181+
public function testDriverKeepsConfiguredJournalMode(): void {
182+
$connection = new WP_SQLite_Connection(
183+
array(
184+
'path' => $this->db_path,
185+
'journal_mode' => 'DELETE',
186+
)
187+
);
188+
189+
$driver = new WP_SQLite_Driver( $connection, 'wp' );
190+
191+
$this->assertSame( 'delete', $this->get_journal_mode( $driver->get_connection() ) );
192+
}
193+
181194
/**
182195
* Create the database file first, and then make its directory read-only,
183196
* so that the WAL sidecar files ("-wal", "-shm") cannot be created.

0 commit comments

Comments
 (0)