Skip to content

Commit 21827ee

Browse files
authored
Revert "Add SQLite database application ID and new consistent file extension" (#335)
Reverts #329
1 parent fd7c8c5 commit 21827ee

6 files changed

Lines changed: 12 additions & 58 deletions

File tree

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
],
6666
"wp-test-php": [
6767
"@wp-test-ensure-env @no_additional_args",
68-
"rm -rf wordpress/src/wp-content/database/.ht.sqlite.php @no_additional_args",
68+
"rm -rf wordpress/src/wp-content/database/.ht.sqlite @no_additional_args",
6969
"npm --prefix wordpress run test:php -- @additional_args"
7070
],
7171
"wp-test-e2e": [
@@ -74,7 +74,7 @@
7474
],
7575
"wp-test-clean": [
7676
"npm --prefix wordpress run env:clean",
77-
"rm -rf wordpress/src/wp-content/database/.ht.sqlite.php"
77+
"rm -rf wordpress/src/wp-content/database/.ht.sqlite"
7878
]
7979
}
8080
}

constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
if ( defined( 'DB_FILE' ) ) {
4949
define( 'FQDB', FQDBDIR . DB_FILE );
5050
} else {
51-
define( 'FQDB', FQDBDIR . '.ht.sqlite.php' );
51+
define( 'FQDB', FQDBDIR . '.ht.sqlite' );
5252
}
5353
}
5454

tests/WP_SQLite_Driver_Tests.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ public function setUp(): void {
1515
$this->sqlite = new $pdo_class( 'sqlite::memory:' );
1616

1717
$this->engine = new WP_SQLite_Driver(
18-
new WP_SQLite_Connection(
19-
array(
20-
'pdo' => $this->sqlite,
21-
'application_id' => 42, // Test application ID.
22-
)
23-
),
18+
new WP_SQLite_Connection( array( 'pdo' => $this->sqlite ) ),
2419
'wp'
2520
);
2621
$this->engine->query(
@@ -56,11 +51,6 @@ private function assertQueryError( $sql, $error_message ) {
5651
$this->assertSame( $error_message, $exception->getMessage() );
5752
}
5853

59-
public function testApplicationID() {
60-
$app_id = $this->sqlite->query( 'PRAGMA application_id' )->fetchColumn();
61-
$this->assertSame( 42, (int) $app_id );
62-
}
63-
6454
public function testRegexp() {
6555
$this->assertQuery(
6656
"INSERT INTO _options (option_name, option_value) VALUES ('rss_0123456789abcdef0123456789abcdef', '1');"

tests/bootstrap.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<?php
22

3-
// Configure the test environment.
4-
error_reporting( E_ALL );
5-
define( 'FQDB', ':memory:' );
6-
define( 'FQDBDIR', __DIR__ . '/../testdb' );
7-
83
require_once __DIR__ . '/wp-sqlite-schema.php';
9-
require_once __DIR__ . '/../constants.php';
104
require_once __DIR__ . '/../wp-pdo-mysql-on-sqlite.php';
115
require_once __DIR__ . '/../wp-includes/sqlite/class-wp-sqlite-query-rewriter.php';
126
require_once __DIR__ . '/../wp-includes/sqlite/class-wp-sqlite-lexer.php';
@@ -20,6 +14,11 @@
2014
define( 'WP_SQLITE_UNSAFE_ENABLE_UNSUPPORTED_VERSIONS', true );
2115
}
2216

17+
// Configure the test environment.
18+
error_reporting( E_ALL );
19+
define( 'FQDB', ':memory:' );
20+
define( 'FQDBDIR', __DIR__ . '/../testdb' );
21+
2322
// Polyfill WPDB globals.
2423
$GLOBALS['table_prefix'] = 'wptests_';
2524
$GLOBALS['wpdb'] = new class() {

wp-includes/sqlite-ast/class-wp-sqlite-connection.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class WP_SQLite_Connection {
6363
* @type int|null $timeout Optional. SQLite timeout in seconds.
6464
* The time to wait for a writable lock.
6565
* @type string|null $journal_mode Optional. SQLite journal mode.
66-
* @type int|null $application_id Optional. SQLite application ID.
6766
* }
6867
*
6968
* @throws InvalidArgumentException When some connection options are invalid.
@@ -97,10 +96,6 @@ public function __construct( array $options ) {
9796
if ( $journal_mode && in_array( $journal_mode, self::SQLITE_JOURNAL_MODES, true ) ) {
9897
$this->query( 'PRAGMA journal_mode = ' . $journal_mode );
9998
}
100-
101-
if ( isset( $options['application_id'] ) ) {
102-
$this->query( 'PRAGMA application_id = ' . (int) $options['application_id'] );
103-
}
10499
}
105100

106101
/**

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

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ class WP_SQLite_DB extends wpdb {
3030
*/
3131
private $allow_unsafe_unquoted_parameters = true;
3232

33-
/**
34-
* The application ID for the SQLite database.
35-
*
36-
* @see https://www.sqlite.org/pragma.html#pragma_application_id
37-
*/
38-
const SQLITE_DB_APPLICATION_ID = 3948349;
39-
4033
/**
4134
* Connects to the SQLite database.
4235
*
@@ -313,28 +306,6 @@ public function db_connect( $allow_bail = true ) {
313306
if ( isset( $GLOBALS['@pdo'] ) ) {
314307
$pdo = $GLOBALS['@pdo'];
315308
}
316-
317-
// Migrate the database file from the legacy default name (".ht.sqlite") to
318-
// the new default name (".ht.sqlite.php"). This only runs when using the
319-
// default file name and the new file does not already exist.
320-
if ( ! defined( 'DB_FILE' ) && ! file_exists( FQDB ) ) {
321-
$old_db_path = FQDBDIR . '.ht.sqlite';
322-
323-
if ( file_exists( $old_db_path ) ) {
324-
if ( ! rename( $old_db_path, FQDB ) ) {
325-
wp_die( 'Failed to rename database file.', 'Error!' );
326-
}
327-
328-
foreach ( array( '-wal', '-shm' ) as $suffix ) {
329-
if ( file_exists( $old_db_path . $suffix ) ) {
330-
if ( ! rename( $old_db_path . $suffix, FQDB . $suffix ) ) {
331-
wp_die( 'Failed to rename database file.', 'Error!' );
332-
}
333-
}
334-
}
335-
}
336-
}
337-
338309
if ( defined( 'WP_SQLITE_AST_DRIVER' ) && WP_SQLITE_AST_DRIVER ) {
339310
if ( null === $this->dbname || '' === $this->dbname ) {
340311
$this->bail(
@@ -350,10 +321,9 @@ public function db_connect( $allow_bail = true ) {
350321
try {
351322
$connection = new WP_SQLite_Connection(
352323
array(
353-
'pdo' => $pdo,
354-
'path' => FQDB,
355-
'journal_mode' => defined( 'SQLITE_JOURNAL_MODE' ) ? SQLITE_JOURNAL_MODE : null,
356-
'application_id' => self::SQLITE_DB_APPLICATION_ID,
324+
'pdo' => $pdo,
325+
'path' => FQDB,
326+
'journal_mode' => defined( 'SQLITE_JOURNAL_MODE' ) ? SQLITE_JOURNAL_MODE : null,
357327
)
358328
);
359329
$this->dbh = new WP_SQLite_Driver( $connection, $this->dbname );

0 commit comments

Comments
 (0)