@@ -20,6 +20,14 @@ class WP_SQLite_Driver {
2020 */
2121 const MYSQL_GRAMMAR_PATH = __DIR__ . '/../../wp-includes/mysql/mysql-grammar.php ' ;
2222
23+ /**
24+ * The minimum required version of SQLite.
25+ *
26+ * Currently, we require SQLite >= 3.37.0 due to the STRICT table support:
27+ * https://www.sqlite.org/stricttables.html
28+ */
29+ const MINIMUM_SQLITE_VERSION = '3.37.0 ' ;
30+
2331 /**
2432 * The default timeout in seconds for SQLite to wait for a writable lock.
2533 */
@@ -365,6 +373,21 @@ public function __construct( array $options ) {
365373 // Return all values (except null) as strings.
366374 $ this ->pdo ->setAttribute ( PDO ::ATTR_STRINGIFY_FETCHES , true );
367375
376+ // Check the SQLite version.
377+ $ sqlite_version = $ this ->get_sqlite_version ();
378+ if ( version_compare ( $ sqlite_version , self ::MINIMUM_SQLITE_VERSION , '< ' ) ) {
379+ throw $ this ->new_driver_exception (
380+ sprintf (
381+ 'The SQLite version %s is not supported. Minimum required version is %s. ' ,
382+ $ sqlite_version ,
383+ self ::MINIMUM_SQLITE_VERSION
384+ )
385+ );
386+ }
387+
388+ // Load SQLite version to a property used by WordPress health info.
389+ $ this ->client_info = $ sqlite_version ;
390+
368391 // Enable foreign keys. By default, they are off.
369392 $ this ->pdo ->query ( 'PRAGMA foreign_keys = ON ' );
370393
@@ -394,9 +417,6 @@ public function __construct( array $options ) {
394417 array ( $ this , 'execute_sqlite_query ' )
395418 );
396419 $ this ->information_schema_builder ->ensure_information_schema_tables ();
397-
398- // Load SQLite version to a property used by WordPress health info.
399- $ this ->client_info = $ this ->get_sqlite_version ();
400420 }
401421
402422 /**
0 commit comments