Skip to content

Commit f691c22

Browse files
authored
Add support for selecting journal mode (#137)
Supporting `WAL` mode is good, however if we add support for that, we should also add supoport for other journaling types as well. This PR adds a `SQLITE_JOURNAL_MODE` constant, and if it has one of the valid & supported values, then we make the query to set the `journal_mode` in the DB. Props @soulteary 👍
1 parent 2561000 commit f691c22

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

wp-includes/sqlite/class-wp-sqlite-translator.php

+5
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ public function __construct( $pdo = null ) {
421421
$this->pdo->query( 'PRAGMA foreign_keys = ON' );
422422
}
423423
$this->pdo->query( 'PRAGMA encoding="UTF-8";' );
424+
425+
$valid_journal_modes = array( 'DELETE', 'TRUNCATE', 'PERSIST', 'MEMORY', 'WAL', 'OFF' );
426+
if ( defined( 'SQLITE_JOURNAL_MODE' ) && in_array( SQLITE_JOURNAL_MODE, $valid_journal_modes, true ) ) {
427+
$this->pdo->query( 'PRAGMA journal_mode = ' . SQLITE_JOURNAL_MODE );
428+
}
424429
}
425430

426431
/**

0 commit comments

Comments
 (0)