Skip to content

Commit

Permalink
Add support for selecting journal mode (#137)
Browse files Browse the repository at this point in the history
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 👍
  • Loading branch information
aristath authored Aug 7, 2024
1 parent 2561000 commit f691c22
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions wp-includes/sqlite/class-wp-sqlite-translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,11 @@ public function __construct( $pdo = null ) {
$this->pdo->query( 'PRAGMA foreign_keys = ON' );
}
$this->pdo->query( 'PRAGMA encoding="UTF-8";' );

$valid_journal_modes = array( 'DELETE', 'TRUNCATE', 'PERSIST', 'MEMORY', 'WAL', 'OFF' );
if ( defined( 'SQLITE_JOURNAL_MODE' ) && in_array( SQLITE_JOURNAL_MODE, $valid_journal_modes, true ) ) {
$this->pdo->query( 'PRAGMA journal_mode = ' . SQLITE_JOURNAL_MODE );
}
}

/**
Expand Down

0 comments on commit f691c22

Please sign in to comment.