Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/mysql-on-sqlite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ version and configuring the SQLite connection:
| Option | Description | Default |
| --- | --- | --- |
| `mysql_version` | MySQL version to emulate, represented as an integer | `80038` |
| `pdo` | Existing PDO SQLite connection | A new connection for `path` |
| `journal_mode` | SQLite journal mode | `WAL` |
| `synchronous` | SQLite synchronous setting | `NORMAL` in WAL mode; otherwise the SQLite default |
| `sqlite_pdo` | Existing PDO SQLite connection | A new connection for `path` |
| `sqlite_journal_mode` | SQLite journal mode | `WAL` |
| `sqlite_synchronous` | SQLite synchronous setting | `NORMAL` in WAL mode; otherwise the SQLite default |

## Compatibility

Expand Down
18 changes: 9 additions & 9 deletions packages/mysql-on-sqlite/src/sqlite/class-wp-mysql-on-sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,15 +774,15 @@ class WP_MySQL_On_SQLite extends PDO {
* @param string|null $username Optional. Ignored by this driver.
* @param string|null $password Optional. Ignored by this driver.
* @param array|null $options {
* Optional driver options.
* Optional PDO attributes and WP_MySQL_On_SQLite options.
*
* Numeric keys are handled as standard PDO constructor options.
* Driver-specific PDO options are not supported.
*
* @type int $mysql_version Optional. MySQL version to emulate. Default 80038.
* @type PDO|null $pdo Optional. Existing PDO SQLite connection.
* @type string|null $journal_mode Optional. SQLite journal mode. Default 'WAL'.
* @type string|int|null $synchronous Optional. SQLite synchronous setting.
* @type int $mysql_version Optional. MySQL version to emulate. Default 80038.
* @type PDO|null $sqlite_pdo Optional. Existing PDO SQLite connection.
* @type string|null $sqlite_journal_mode Optional. SQLite journal mode. Default 'WAL'.
* @type string|int|null $sqlite_synchronous Optional. SQLite synchronous setting.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Searches: Veloria, GitHub.

The only non-vendored external consumer that passes these options is Automattic/markdown-database-integration, which uses pdo and journal_mode and can be updated alongside this change. The other GitHub matches are vendored copies of this repository; Veloria finds no WordPress.org plugin consumers.

* }
*
* @throws InvalidArgumentException When the MySQL version is invalid.
Expand Down Expand Up @@ -862,12 +862,12 @@ function ( $key ) {
}

$connection_options = array(
'journal_mode' => $options['journal_mode'] ?? null,
'synchronous' => $options['synchronous'] ?? null,
'journal_mode' => $options['sqlite_journal_mode'] ?? null,
'synchronous' => $options['sqlite_synchronous'] ?? null,
'pdo_options' => $connection_pdo_options,
);
if ( isset( $options['pdo'] ) ) {
$connection_options['pdo'] = $options['pdo'];
if ( isset( $options['sqlite_pdo'] ) ) {
$connection_options['pdo'] = $options['sqlite_pdo'];
} else {
$connection_options['path'] = $path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public function __construct(
null,
null,
array(
'mysql_version' => $mysql_version,
'pdo' => $connection->get_pdo(),
'journal_mode' => $connection->query( 'PRAGMA journal_mode' )->fetchColumn(),
'mysql_version' => $mysql_version,
'sqlite_pdo' => $connection->get_pdo(),
'sqlite_journal_mode' => $connection->query( 'PRAGMA journal_mode' )->fetchColumn(),
)
);
$this->client_info = $this->mysql_on_sqlite_driver->client_info;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ private function create_driver( WP_SQLite_Connection $connection ): WP_MySQL_On_
null,
null,
array(
'pdo' => $connection->get_pdo(),
'journal_mode' => $connection->query( 'PRAGMA journal_mode' )->fetchColumn(),
'sqlite_pdo' => $connection->get_pdo(),
'sqlite_journal_mode' => $connection->query( 'PRAGMA journal_mode' )->fetchColumn(),
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function setUp(): void {
'mysql-on-sqlite:dbname=wp',
null,
null,
array( 'pdo' => $this->sqlite )
array( 'sqlite_pdo' => $this->sqlite )
);
$this->engine->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function test_constructor_reports_stringify_fetches_from_injected_pdo():
'mysql-on-sqlite:dbname=wp',
null,
null,
array( 'pdo' => $pdo )
array( 'sqlite_pdo' => $pdo )
);

$this->assertTrue( $driver->getAttribute( PDO::ATTR_STRINGIFY_FETCHES ) );
Expand Down Expand Up @@ -260,7 +260,7 @@ public function test_exposes_underlying_sqlite_pdo(): void {
'mysql-on-sqlite:dbname=wp',
null,
null,
array( 'pdo' => $pdo )
array( 'sqlite_pdo' => $pdo )
);

$this->assertSame( $pdo, $driver->get_sqlite_pdo() );
Expand Down Expand Up @@ -330,8 +330,8 @@ public function test_journal_mode_and_synchronous_driver_options(): void {
null,
null,
array(
'journal_mode' => 'DELETE',
'synchronous' => 'FULL',
'sqlite_journal_mode' => 'DELETE',
'sqlite_synchronous' => 'FULL',
)
);
$connection = $driver->get_connection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function setUp(): void {
'mysql-on-sqlite:dbname=wp',
null,
null,
array( 'pdo' => $this->sqlite )
array( 'sqlite_pdo' => $this->sqlite )
);
$this->engine->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );

Expand Down
12 changes: 6 additions & 6 deletions packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function setUp(): void {
'mysql-on-sqlite:dbname=wp',
null,
null,
array( 'pdo' => $this->sqlite )
array( 'sqlite_pdo' => $this->sqlite )
);
$this->engine->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );
$this->query(
Expand Down Expand Up @@ -2932,7 +2932,7 @@ public function testMySQL57PreservesUnnamedSqlModeBit() {
null,
null,
array(
'pdo' => $this->sqlite,
'sqlite_pdo' => $this->sqlite,
'mysql_version' => 50744,
)
);
Expand All @@ -2950,7 +2950,7 @@ public function testSqlModeValidationUsesEmulatedMySQLVersion() {
null,
null,
array(
'pdo' => $this->sqlite,
'sqlite_pdo' => $this->sqlite,
'mysql_version' => 50744,
)
);
Expand Down Expand Up @@ -2994,7 +2994,7 @@ public function testMySQL57RejectsNotUsedSqlModeName() {
null,
null,
array(
'pdo' => $this->sqlite,
'sqlite_pdo' => $this->sqlite,
'mysql_version' => 50744,
)
);
Expand Down Expand Up @@ -3048,7 +3048,7 @@ public function testSqlModeDefaultUsesEmulatedMySQLVersion() {
null,
null,
array(
'pdo' => $this->sqlite,
'sqlite_pdo' => $this->sqlite,
'mysql_version' => 50744,
)
);
Expand Down Expand Up @@ -7321,7 +7321,7 @@ public function testDatabaseNameEmpty(): void {
'mysql-on-sqlite:dbname=',
null,
null,
array( 'pdo' => $pdo )
array( 'sqlite_pdo' => $pdo )
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function testDriverKeepsConfiguredJournalMode(): void {
sprintf( 'mysql-on-sqlite:path=%s;dbname=wp', $this->db_path ),
null,
null,
array( 'journal_mode' => 'DELETE' )
array( 'sqlite_journal_mode' => 'DELETE' )
);

$this->assertSame( 'delete', $this->get_journal_mode( $driver->get_connection() ) );
Expand Down
2 changes: 1 addition & 1 deletion packages/mysql-on-sqlite/tests/WP_SQLite_DB_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function setUp(): void {
'mysql-on-sqlite:dbname=wp',
null,
null,
array( 'pdo' => $pdo )
array( 'sqlite_pdo' => $pdo )
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function setUp(): void {
'mysql-on-sqlite:dbname=wp',
null,
null,
array( 'pdo' => $this->sqlite )
array( 'sqlite_pdo' => $this->sqlite )
);
$this->engine->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public function db_connect( $allow_bail = true ) {

try {
$options = array(
'journal_mode' => defined( 'SQLITE_JOURNAL_MODE' ) ? SQLITE_JOURNAL_MODE : null,
'sqlite_journal_mode' => defined( 'SQLITE_JOURNAL_MODE' ) ? SQLITE_JOURNAL_MODE : null,
);
$dbh = new WP_MySQL_On_SQLite(
sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function sqlite_make_db_sqlite() {
null,
null,
array(
'journal_mode' => defined( 'SQLITE_JOURNAL_MODE' ) ? SQLITE_JOURNAL_MODE : null,
'sqlite_journal_mode' => defined( 'SQLITE_JOURNAL_MODE' ) ? SQLITE_JOURNAL_MODE : null,
)
);
$translator->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true ); // phpcs:ignore WordPress.DB.RestrictedClasses.mysql__PDO
Expand Down
Loading