Skip to content

Commit 8354291

Browse files
authored
Prefix SQLite-specific constructor options (#481)
## Summary Rename the SQLite-specific `WP_MySQL_On_SQLite` constructor options so their ownership is explicit: - `pdo` → `sqlite_pdo` - `journal_mode` → `sqlite_journal_mode` - `synchronous` → `sqlite_synchronous` The documentation, internal callers, and tests now use the prefixed names. ## Rationale `WP_MySQL_On_SQLite` accepts standard numeric PDO constructor options alongside its own string-keyed options. The generic names did not clearly distinguish SQLite connection configuration from PDO attributes or other driver configuration. The `sqlite_` prefix makes that boundary explicit.
1 parent 1f557c2 commit 8354291

13 files changed

Lines changed: 34 additions & 34 deletions

‎packages/mysql-on-sqlite/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ version and configuring the SQLite connection:
7373
| Option | Description | Default |
7474
| --- | --- | --- |
7575
| `mysql_version` | MySQL version to emulate, represented as an integer | `80038` |
76-
| `pdo` | Existing PDO SQLite connection | A new connection for `path` |
77-
| `journal_mode` | SQLite journal mode | `WAL` |
78-
| `synchronous` | SQLite synchronous setting | `NORMAL` in WAL mode; otherwise the SQLite default |
76+
| `sqlite_pdo` | Existing PDO SQLite connection | A new connection for `path` |
77+
| `sqlite_journal_mode` | SQLite journal mode | `WAL` |
78+
| `sqlite_synchronous` | SQLite synchronous setting | `NORMAL` in WAL mode; otherwise the SQLite default |
7979

8080
## Compatibility
8181

‎packages/mysql-on-sqlite/src/sqlite/class-wp-mysql-on-sqlite.php‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -774,15 +774,15 @@ class WP_MySQL_On_SQLite extends PDO {
774774
* @param string|null $username Optional. Ignored by this driver.
775775
* @param string|null $password Optional. Ignored by this driver.
776776
* @param array|null $options {
777-
* Optional driver options.
777+
* Optional PDO attributes and WP_MySQL_On_SQLite options.
778778
*
779779
* Numeric keys are handled as standard PDO constructor options.
780780
* Driver-specific PDO options are not supported.
781781
*
782-
* @type int $mysql_version Optional. MySQL version to emulate. Default 80038.
783-
* @type PDO|null $pdo Optional. Existing PDO SQLite connection.
784-
* @type string|null $journal_mode Optional. SQLite journal mode. Default 'WAL'.
785-
* @type string|int|null $synchronous Optional. SQLite synchronous setting.
782+
* @type int $mysql_version Optional. MySQL version to emulate. Default 80038.
783+
* @type PDO|null $sqlite_pdo Optional. Existing PDO SQLite connection.
784+
* @type string|null $sqlite_journal_mode Optional. SQLite journal mode. Default 'WAL'.
785+
* @type string|int|null $sqlite_synchronous Optional. SQLite synchronous setting.
786786
* }
787787
*
788788
* @throws InvalidArgumentException When the MySQL version is invalid.
@@ -862,12 +862,12 @@ function ( $key ) {
862862
}
863863

864864
$connection_options = array(
865-
'journal_mode' => $options['journal_mode'] ?? null,
866-
'synchronous' => $options['synchronous'] ?? null,
865+
'journal_mode' => $options['sqlite_journal_mode'] ?? null,
866+
'synchronous' => $options['sqlite_synchronous'] ?? null,
867867
'pdo_options' => $connection_pdo_options,
868868
);
869-
if ( isset( $options['pdo'] ) ) {
870-
$connection_options['pdo'] = $options['pdo'];
869+
if ( isset( $options['sqlite_pdo'] ) ) {
870+
$connection_options['pdo'] = $options['sqlite_pdo'];
871871
} else {
872872
$connection_options['path'] = $path;
873873
}

‎packages/mysql-on-sqlite/src/sqlite/class-wp-sqlite-driver.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ public function __construct(
8282
null,
8383
null,
8484
array(
85-
'mysql_version' => $mysql_version,
86-
'pdo' => $connection->get_pdo(),
87-
'journal_mode' => $connection->query( 'PRAGMA journal_mode' )->fetchColumn(),
85+
'mysql_version' => $mysql_version,
86+
'sqlite_pdo' => $connection->get_pdo(),
87+
'sqlite_journal_mode' => $connection->query( 'PRAGMA journal_mode' )->fetchColumn(),
8888
)
8989
);
9090
$this->client_info = $this->mysql_on_sqlite_driver->client_info;

‎packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Concurrency_Tests.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ private function create_driver( WP_SQLite_Connection $connection ): WP_MySQL_On_
178178
null,
179179
null,
180180
array(
181-
'pdo' => $connection->get_pdo(),
182-
'journal_mode' => $connection->query( 'PRAGMA journal_mode' )->fetchColumn(),
181+
'sqlite_pdo' => $connection->get_pdo(),
182+
'sqlite_journal_mode' => $connection->query( 'PRAGMA journal_mode' )->fetchColumn(),
183183
)
184184
);
185185
}

‎packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Metadata_Tests.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function setUp(): void {
2020
'mysql-on-sqlite:dbname=wp',
2121
null,
2222
null,
23-
array( 'pdo' => $this->sqlite )
23+
array( 'sqlite_pdo' => $this->sqlite )
2424
);
2525
$this->engine->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );
2626
}

‎packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_PDO_API_Tests.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function test_constructor_reports_stringify_fetches_from_injected_pdo():
214214
'mysql-on-sqlite:dbname=wp',
215215
null,
216216
null,
217-
array( 'pdo' => $pdo )
217+
array( 'sqlite_pdo' => $pdo )
218218
);
219219

220220
$this->assertTrue( $driver->getAttribute( PDO::ATTR_STRINGIFY_FETCHES ) );
@@ -260,7 +260,7 @@ public function test_exposes_underlying_sqlite_pdo(): void {
260260
'mysql-on-sqlite:dbname=wp',
261261
null,
262262
null,
263-
array( 'pdo' => $pdo )
263+
array( 'sqlite_pdo' => $pdo )
264264
);
265265

266266
$this->assertSame( $pdo, $driver->get_sqlite_pdo() );
@@ -330,8 +330,8 @@ public function test_journal_mode_and_synchronous_driver_options(): void {
330330
null,
331331
null,
332332
array(
333-
'journal_mode' => 'DELETE',
334-
'synchronous' => 'FULL',
333+
'sqlite_journal_mode' => 'DELETE',
334+
'sqlite_synchronous' => 'FULL',
335335
)
336336
);
337337
$connection = $driver->get_connection();

‎packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Query_Tests.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function setUp(): void {
113113
'mysql-on-sqlite:dbname=wp',
114114
null,
115115
null,
116-
array( 'pdo' => $this->sqlite )
116+
array( 'sqlite_pdo' => $this->sqlite )
117117
);
118118
$this->engine->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );
119119

‎packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Tests.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function setUp(): void {
3737
'mysql-on-sqlite:dbname=wp',
3838
null,
3939
null,
40-
array( 'pdo' => $this->sqlite )
40+
array( 'sqlite_pdo' => $this->sqlite )
4141
);
4242
$this->engine->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );
4343
$this->query(
@@ -2932,7 +2932,7 @@ public function testMySQL57PreservesUnnamedSqlModeBit() {
29322932
null,
29332933
null,
29342934
array(
2935-
'pdo' => $this->sqlite,
2935+
'sqlite_pdo' => $this->sqlite,
29362936
'mysql_version' => 50744,
29372937
)
29382938
);
@@ -2950,7 +2950,7 @@ public function testSqlModeValidationUsesEmulatedMySQLVersion() {
29502950
null,
29512951
null,
29522952
array(
2953-
'pdo' => $this->sqlite,
2953+
'sqlite_pdo' => $this->sqlite,
29542954
'mysql_version' => 50744,
29552955
)
29562956
);
@@ -2994,7 +2994,7 @@ public function testMySQL57RejectsNotUsedSqlModeName() {
29942994
null,
29952995
null,
29962996
array(
2997-
'pdo' => $this->sqlite,
2997+
'sqlite_pdo' => $this->sqlite,
29982998
'mysql_version' => 50744,
29992999
)
30003000
);
@@ -3048,7 +3048,7 @@ public function testSqlModeDefaultUsesEmulatedMySQLVersion() {
30483048
null,
30493049
null,
30503050
array(
3051-
'pdo' => $this->sqlite,
3051+
'sqlite_pdo' => $this->sqlite,
30523052
'mysql_version' => 50744,
30533053
)
30543054
);
@@ -7321,7 +7321,7 @@ public function testDatabaseNameEmpty(): void {
73217321
'mysql-on-sqlite:dbname=',
73227322
null,
73237323
null,
7324-
array( 'pdo' => $pdo )
7324+
array( 'sqlite_pdo' => $pdo )
73257325
);
73267326
}
73277327

‎packages/mysql-on-sqlite/tests/WP_SQLite_Connection_Tests.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function testDriverKeepsConfiguredJournalMode(): void {
183183
sprintf( 'mysql-on-sqlite:path=%s;dbname=wp', $this->db_path ),
184184
null,
185185
null,
186-
array( 'journal_mode' => 'DELETE' )
186+
array( 'sqlite_journal_mode' => 'DELETE' )
187187
);
188188

189189
$this->assertSame( 'delete', $this->get_journal_mode( $driver->get_connection() ) );

‎packages/mysql-on-sqlite/tests/WP_SQLite_DB_Tests.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function setUp(): void {
1717
'mysql-on-sqlite:dbname=wp',
1818
null,
1919
null,
20-
array( 'pdo' => $pdo )
20+
array( 'sqlite_pdo' => $pdo )
2121
);
2222
}
2323

0 commit comments

Comments
 (0)