Skip to content

Commit 191333a

Browse files
committed
Check for 64-bit PHP before enabling SQLite in WordPress
Show the PHP requirement in setup and stop before installing the drop-in. Also check existing installations before initializing database storage. #638
1 parent 955b098 commit 191333a

8 files changed

Lines changed: 22 additions & 5 deletions

File tree

‎composer.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"require": {
1111
"php": ">=7.2",
12+
"php-64bit": "*",
1213
"ext-pdo": "*",
1314
"ext-pdo_sqlite": "*"
1415
},

‎packages/plugin-sqlite-database-integration/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ The archive is written to `build/plugin-sqlite-database-integration.zip`.
8383
## Requirements
8484

8585
- **WordPress:** 6.4+
86-
- **PHP:** 7.2+
86+
- **PHP:** 7.2+ (64-bit)
8787
- **PHP extensions:** `pdo`, `pdo_sqlite`
8888
- **SQLite:** 3.37.0+
8989

‎packages/plugin-sqlite-database-integration/activate.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ function ( $result ) {
7171
* When the plugin gets merged in wp-core, this is not to be ported.
7272
*/
7373
function sqlite_plugin_copy_db_file() {
74-
// Bail early if the pdo_sqlite extension is not loaded.
75-
if ( ! extension_loaded( 'pdo_sqlite' ) ) {
74+
if ( PHP_INT_SIZE < 8 || ! extension_loaded( 'pdo_sqlite' ) ) {
7675
return;
7776
}
7877

‎packages/plugin-sqlite-database-integration/admin-notices.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ function sqlite_plugin_admin_notice() {
1919
return;
2020
}
2121

22+
if ( PHP_INT_SIZE < 8 ) {
23+
printf(
24+
'<div class="notice notice-error"><p>%s</p></div>',
25+
esc_html__( 'The SQLite Integration plugin requires 64-bit PHP. Please switch to a 64-bit PHP installation before enabling SQLite.', 'sqlite-database-integration' )
26+
);
27+
return;
28+
}
29+
2230
// Bail early if the pdo_sqlite extension is not loaded.
2331
if ( ! extension_loaded( 'pdo_sqlite' ) ) {
2432
printf(

‎packages/plugin-sqlite-database-integration/admin-page.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ function sqlite_integration_admin_screen() {
6666
);
6767
?>
6868
</p>
69+
<?php elseif ( PHP_INT_SIZE < 8 ) : ?>
70+
<div class="notice notice-error">
71+
<p><?php esc_html_e( 'The SQLite Integration plugin requires 64-bit PHP. Please switch to a 64-bit PHP installation before enabling SQLite.', 'sqlite-database-integration' ); ?></p>
72+
</div>
6973
<?php elseif ( ! extension_loaded( 'pdo_sqlite' ) ) : ?>
7074
<div class="notice notice-error">
7175
<p><?php esc_html_e( 'We detected that the PDO SQLite driver is missing from your server (the pdo_sqlite extension is not loaded). Please make sure that SQLite is enabled in your PHP installation before proceeding.', 'sqlite-database-integration' ); ?></p>

‎packages/plugin-sqlite-database-integration/composer.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"require": {
1111
"php": ">=7.2",
12+
"php-64bit": "*",
1213
"ext-pdo": "*",
1314
"ext-pdo_sqlite": "*"
1415
}

‎packages/plugin-sqlite-database-integration/readme.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The plugin replaces the default MySQL database layer with an SQLite-backed imple
2828

2929
**Important:** Enabling SQLite creates a separate, empty database; it does not migrate an existing site. If you enable it on a site that uses MySQL or MariaDB, WordPress will ask you to set up the site again. Disabling the plugin reconnects WordPress to the previous database with its data unchanged. Changes made while using SQLite are not transferred.
3030

31-
The plugin requires the PDO SQLite PHP extension and SQLite 3.37.0 or newer.
31+
The plugin requires 64-bit PHP with the PDO SQLite extension and SQLite 3.37.0 or newer.
3232

3333
== Frequently Asked Questions ==
3434

@@ -75,7 +75,7 @@ The value of `DB_PATH` must be an absolute path to the SQLite database file, or
7575

7676
= What does the plugin require? =
7777

78-
In addition to the WordPress and PHP versions listed above, the plugin requires the PDO SQLite PHP extension and SQLite 3.37.0 or newer. The setup screen also needs write access to the `wp-content` directory and will detect conflicting database drop-ins.
78+
In addition to the WordPress and PHP versions listed above, the plugin requires 64-bit PHP with the PDO SQLite extension and SQLite 3.37.0 or newer. The setup screen also needs write access to the `wp-content` directory and will detect conflicting database drop-ins.
7979

8080
= Where can I submit my plugin feedback? =
8181

‎packages/plugin-sqlite-database-integration/wp-includes/sqlite/db.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
return;
1818
}
1919

20+
if ( PHP_INT_SIZE < 8 ) {
21+
throw new RuntimeException( 'The SQLite Integration plugin requires 64-bit PHP.' );
22+
}
23+
2024
if ( ! extension_loaded( 'pdo' ) ) {
2125
wp_die(
2226
new WP_Error(

0 commit comments

Comments
 (0)