Skip to content

Commit 30281b8

Browse files
committed
Rename MySQL-on-SQLite driver class
Rename WP_PDO_MySQL_On_SQLite to WP_MySQL_On_SQLite and align the implementation and test filenames with the public class name.
1 parent 8f62983 commit 30281b8

20 files changed

Lines changed: 76 additions & 76 deletions

‎.github/workflows/wp-tests-phpunit-native-extension-setup.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ if ( ! ( $parser_ast instanceof WP_MySQL_Native_Parser_Node ) ) {
149149
wp_sqlite_native_parser_verification_fail( 'Native parser did not produce a native-backed AST in the WordPress PHP test container.' );
150150
}
151151
152-
$driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp;' );
152+
$driver = new WP_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp;' );
153153
$parser = $driver->create_parser( 'SELECT 1' );
154154
wp_sqlite_assert_native_parser_delegate( $parser, 'WordPress PHP test container SQLite driver did not create a native parser delegate.' );
155155
$parser->next_query();

‎packages/mysql-on-sqlite/src/load.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
define( 'WP_MYSQL_ON_SQLITE_LOADER_PATH', __FILE__ );
44

55
/**
6-
* Load the PDO MySQL-on-SQLite driver and its dependencies.
6+
* Load the MySQL-on-SQLite driver and its dependencies.
77
*/
88
require_once __DIR__ . '/php-polyfills.php';
99
require_once __DIR__ . '/version.php';
@@ -40,5 +40,5 @@
4040
require_once __DIR__ . '/sqlite/class-wp-sqlite-information-schema-exception.php';
4141
require_once __DIR__ . '/sqlite/class-wp-sqlite-information-schema-reconstructor.php';
4242
require_once __DIR__ . '/sqlite/class-wp-sqlite-pdo-user-defined-functions.php';
43-
require_once __DIR__ . '/sqlite/class-wp-pdo-mysql-on-sqlite.php';
43+
require_once __DIR__ . '/sqlite/class-wp-mysql-on-sqlite.php';
4444
require_once __DIR__ . '/sqlite/class-wp-pdo-proxy-statement.php';

packages/mysql-on-sqlite/src/sqlite/class-wp-pdo-mysql-on-sqlite.php renamed to packages/mysql-on-sqlite/src/sqlite/class-wp-mysql-on-sqlite.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* The driver requires PDO with the SQLite driver, and the PCRE engine.
1616
*/
17-
class WP_PDO_MySQL_On_SQLite extends PDO {
17+
class WP_MySQL_On_SQLite extends PDO {
1818
/**
1919
* The path to the MySQL SQL grammar file.
2020
*/
@@ -4211,7 +4211,7 @@ private function translate_query_expression( WP_Parser_Node $node ): string {
42114211
* When the ORDER BY clause is present, we need to disambiguate the item
42124212
* list and make sure they don't cause an "ambiguous column name" error.
42134213
*
4214-
* @see WP_PDO_MySQL_On_SQLite::disambiguate_item()
4214+
* @see WP_MySQL_On_SQLite::disambiguate_item()
42154215
*/
42164216
$disambiguated_order_list = array();
42174217
$order_clause = $node->get_first_child_node( 'orderClause' );
@@ -4279,7 +4279,7 @@ private function translate_query_specification( WP_Parser_Node $node ): string {
42794279
* When the GROUP BY or HAVING clause is present, we need to disambiguate
42804280
* the items to ensure they don't cause an "ambiguous column name" error.
42814281
*
4282-
* @see WP_PDO_MySQL_On_SQLite::disambiguate_item()
4282+
* @see WP_MySQL_On_SQLite::disambiguate_item()
42834283
*/
42844284
$group_by_clause = null;
42854285
$having_clause = null;
@@ -5788,7 +5788,7 @@ private function unnest_parenthesized_expression( WP_Parser_Node $node ): WP_Par
57885788
* consider column references in forms like "db.table.column".
57895789
*
57905790
* @param array $disambiguation_map The SELECT item disambiguation map (column name => array of select items).
5791-
* @see WP_PDO_MySQL_On_SQLite::create_select_item_disambiguation_map()
5791+
* @see WP_MySQL_On_SQLite::create_select_item_disambiguation_map()
57925792
* @param WP_Parser_Node $expr The expression AST node or subnode.
57935793
* @return string|null The disambiguated and translated expression;
57945794
* null when the expression cannot be disambiguated.
@@ -5827,7 +5827,7 @@ private function disambiguate_item( array $disambiguation_map, WP_Parser_Node $e
58275827
* Create a SELECT item disambiguation map from a SELECT item list for use
58285828
* with the ORDER BY, GROUP BY, and HAVING clause disambiguation algorithm.
58295829
*
5830-
* @see WP_PDO_MySQL_On_SQLite::disambiguate_item()
5830+
* @see WP_MySQL_On_SQLite::disambiguate_item()
58315831
*
58325832
* @param WP_Parser_Node $select_item_list The "selectItemList" AST node.
58335833
* @return array The SELECT item disambiguation map (column name => array of select items).

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class WP_SQLite_Configurator {
1414
/**
1515
* The SQLite driver instance.
1616
*
17-
* @var WP_PDO_MySQL_On_SQLite
17+
* @var WP_MySQL_On_SQLite
1818
*/
1919
private $driver;
2020

@@ -35,11 +35,11 @@ class WP_SQLite_Configurator {
3535
/**
3636
* Constructor.
3737
*
38-
* @param WP_PDO_MySQL_On_SQLite $driver The SQLite driver instance.
38+
* @param WP_MySQL_On_SQLite $driver The SQLite driver instance.
3939
* @param WP_SQLite_Information_Schema_Builder $schema_builder The information schema builder instance.
4040
*/
4141
public function __construct(
42-
WP_PDO_MySQL_On_SQLite $driver,
42+
WP_MySQL_On_SQLite $driver,
4343
WP_SQLite_Information_Schema_Builder $schema_builder
4444
) {
4545
$this->driver = $driver;
@@ -100,7 +100,7 @@ private function ensure_global_variables_table(): void {
100100
sprintf(
101101
'CREATE TABLE IF NOT EXISTS %s (name TEXT PRIMARY KEY, value TEXT)',
102102
$this->driver->get_connection()->quote_identifier(
103-
WP_PDO_MySQL_On_SQLite::GLOBAL_VARIABLES_TABLE_NAME
103+
WP_MySQL_On_SQLite::GLOBAL_VARIABLES_TABLE_NAME
104104
)
105105
)
106106
);
@@ -260,11 +260,11 @@ private function save_current_driver_version(): void {
260260
sprintf(
261261
'INSERT INTO %s (name, value) VALUES (?, ?) ON CONFLICT(name) DO UPDATE SET value = ?',
262262
$this->driver->get_connection()->quote_identifier(
263-
WP_PDO_MySQL_On_SQLite::GLOBAL_VARIABLES_TABLE_NAME
263+
WP_MySQL_On_SQLite::GLOBAL_VARIABLES_TABLE_NAME
264264
)
265265
),
266266
array(
267-
WP_PDO_MySQL_On_SQLite::DRIVER_VERSION_VARIABLE_NAME,
267+
WP_MySQL_On_SQLite::DRIVER_VERSION_VARIABLE_NAME,
268268
SQLITE_DRIVER_VERSION,
269269
SQLITE_DRIVER_VERSION,
270270
)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ class WP_SQLite_Driver_Exception extends PDOException {
44
/**
55
* The SQLite driver that originated the exception.
66
*
7-
* @var WP_PDO_MySQL_On_SQLite
7+
* @var WP_MySQL_On_SQLite
88
*/
99
private $driver;
1010

1111
/**
1212
* Constructor.
1313
*
14-
* @param WP_PDO_MySQL_On_SQLite $driver The SQLite driver that originated the exception.
14+
* @param WP_MySQL_On_SQLite $driver The SQLite driver that originated the exception.
1515
* @param string $message The exception message.
1616
* @param int|string $code The exception code. In PDO, it can be a string with value of SQLSTATE.
1717
* @param Throwable|null $previous The previous throwable used for the exception chaining.
1818
*/
1919
public function __construct(
20-
WP_PDO_MySQL_On_SQLite $driver,
20+
WP_MySQL_On_SQLite $driver,
2121
string $message,
2222
$code = 0,
2323
?Throwable $previous = null
@@ -27,7 +27,7 @@ public function __construct(
2727
$this->driver = $driver;
2828
}
2929

30-
public function getDriver(): WP_PDO_MySQL_On_SQLite {
30+
public function getDriver(): WP_MySQL_On_SQLite {
3131
return $this->driver;
3232
}
3333
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class WP_SQLite_Information_Schema_Reconstructor {
1919
/**
2020
* The SQLite driver instance.
2121
*
22-
* @var WP_PDO_MySQL_On_SQLite
22+
* @var WP_MySQL_On_SQLite
2323
*/
2424
private $driver;
2525

@@ -40,7 +40,7 @@ class WP_SQLite_Information_Schema_Reconstructor {
4040
/**
4141
* Constructor.
4242
*
43-
* @param WP_PDO_MySQL_On_SQLite $driver The SQLite driver instance.
43+
* @param WP_MySQL_On_SQLite $driver The SQLite driver instance.
4444
* @param WP_SQLite_Information_Schema_Builder $schema_builder The information schema builder instance.
4545
*/
4646
public function __construct(
@@ -137,7 +137,7 @@ private function get_sqlite_table_names(): array {
137137
array(
138138
'_mysql_data_types_cache',
139139
'sqlite\_%',
140-
str_replace( '_', '\_', WP_PDO_MySQL_On_SQLite::RESERVED_PREFIX ) . '%',
140+
str_replace( '_', '\_', WP_MySQL_On_SQLite::RESERVED_PREFIX ) . '%',
141141
)
142142
)->fetchAll( PDO::FETCH_COLUMN );
143143
}
@@ -763,9 +763,9 @@ private function get_mysql_column_type( string $column_type ): string {
763763
/**
764764
* Format a MySQL UTF-8 string literal for output in a CREATE TABLE statement.
765765
*
766-
* See WP_PDO_MySQL_On_SQLite::quote_mysql_utf8_string_literal().
766+
* See WP_MySQL_On_SQLite::quote_mysql_utf8_string_literal().
767767
*
768-
* TODO: This is a copy of WP_PDO_MySQL_On_SQLite::quote_mysql_utf8_string_literal().
768+
* TODO: This is a copy of WP_MySQL_On_SQLite::quote_mysql_utf8_string_literal().
769769
* We may consider extracing it to reusable MySQL helpers.
770770
*
771771
* @param string $utf8_literal The UTF-8 string literal to escape.

packages/mysql-on-sqlite/tests/WP_SQLite_Driver_Concurrency_Tests.php renamed to packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Concurrency_Tests.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Tests for concurrent access to the same SQLite database file.
77
*/
8-
class WP_SQLite_Driver_Concurrency_Tests extends TestCase {
8+
class WP_MySQL_On_SQLite_Concurrency_Tests extends TestCase {
99
/**
1010
* Path to the temporary SQLite database file used in file-based tests.
1111
*
@@ -165,15 +165,15 @@ private function assertReadOnlyQuerySucceedsUnderWriteLock( string $query ): voi
165165
}
166166
}
167167

168-
private function create_in_memory_driver(): WP_PDO_MySQL_On_SQLite {
168+
private function create_in_memory_driver(): WP_MySQL_On_SQLite {
169169
$pdo_class = PHP_VERSION_ID >= 80400 ? PDO\SQLite::class : PDO::class;
170170
$pdo = new $pdo_class( 'sqlite::memory:' );
171171
$connection = new WP_SQLite_Connection( array( 'pdo' => $pdo ) );
172172
return $this->create_driver( $connection );
173173
}
174174

175-
private function create_driver( WP_SQLite_Connection $connection ): WP_PDO_MySQL_On_SQLite {
176-
return new WP_PDO_MySQL_On_SQLite(
175+
private function create_driver( WP_SQLite_Connection $connection ): WP_MySQL_On_SQLite {
176+
return new WP_MySQL_On_SQLite(
177177
'mysql-on-sqlite:dbname=wp',
178178
null,
179179
null,

packages/mysql-on-sqlite/tests/WP_SQLite_Driver_Metadata_Tests.php renamed to packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Metadata_Tests.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
use PHPUnit\Framework\TestCase;
44

5-
class WP_SQLite_Driver_Metadata_Tests extends TestCase {
6-
/** @var WP_PDO_MySQL_On_SQLite */
5+
class WP_MySQL_On_SQLite_Metadata_Tests extends TestCase {
6+
/** @var WP_MySQL_On_SQLite */
77
private $engine;
88

99
/** @var PDO */
@@ -16,7 +16,7 @@ class WP_SQLite_Driver_Metadata_Tests extends TestCase {
1616
public function setUp(): void {
1717
$pdo_class = PHP_VERSION_ID >= 80400 ? PDO\SQLite::class : PDO::class;
1818
$this->sqlite = new $pdo_class( 'sqlite::memory:' );
19-
$this->engine = new WP_PDO_MySQL_On_SQLite(
19+
$this->engine = new WP_MySQL_On_SQLite(
2020
'mysql-on-sqlite:dbname=wp',
2121
null,
2222
null,

packages/mysql-on-sqlite/tests/WP_PDO_MySQL_On_SQLite_PDO_API_Tests.php renamed to packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_PDO_API_Tests.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ public function __construct( $arg1 = null, $arg2 = null ) {
1616
}
1717
}
1818

19-
class WP_PDO_MySQL_On_SQLite_PDO_API_Tests extends TestCase {
20-
/** @var WP_PDO_MySQL_On_SQLite */
19+
class WP_MySQL_On_SQLite_PDO_API_Tests extends TestCase {
20+
/** @var WP_MySQL_On_SQLite */
2121
private $driver;
2222

2323
public function setUp(): void {
24-
$this->driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp;' );
24+
$this->driver = new WP_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp;' );
2525

2626
// Run all tests with stringified fetch mode results, so we can use
2727
// assertions that are consistent across all tested PHP versions.
@@ -30,41 +30,41 @@ public function setUp(): void {
3030
}
3131

3232
public function test_connection(): void {
33-
$driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=WordPress;' );
33+
$driver = new WP_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=WordPress;' );
3434
$this->assertInstanceOf( PDO::class, $driver );
3535
}
3636

3737
public function test_dsn_parsing(): void {
3838
// Standard DSN.
39-
$driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp' );
39+
$driver = new WP_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp' );
4040
$this->assertSame( 'wp', $driver->query( 'SELECT DATABASE()' )->fetch()[0] );
4141

4242
// DSN with trailing semicolon.
43-
$driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp;' );
43+
$driver = new WP_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp;' );
4444
$this->assertSame( 'wp', $driver->query( 'SELECT DATABASE()' )->fetch()[0] );
4545

4646
// DSN with whitespace before argument names.
47-
$driver = new WP_PDO_MySQL_On_SQLite( "mysql-on-sqlite: path=:memory:; \n\r\t\v\fdbname=wp" );
47+
$driver = new WP_MySQL_On_SQLite( "mysql-on-sqlite: path=:memory:; \n\r\t\v\fdbname=wp" );
4848
$this->assertSame( 'wp', $driver->query( 'SELECT DATABASE()' )->fetch()[0] );
4949

5050
// DSN with whitespace in the database name.
51-
$driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname= w p ' );
51+
$driver = new WP_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname= w p ' );
5252
$this->assertSame( ' w p ', $driver->query( 'SELECT DATABASE()' )->fetch()[0] );
5353

5454
// DSN with semicolon in the database name.
55-
$driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp;dbname=w;;p;' );
55+
$driver = new WP_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp;dbname=w;;p;' );
5656
$this->assertSame( 'w;p', $driver->query( 'SELECT DATABASE()' )->fetch()[0] );
5757

5858
// DSN with semicolon in the database name and a terminating semicolon.
59-
$driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=w;;;p' );
59+
$driver = new WP_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=w;;;p' );
6060
$this->assertSame( 'w;', $driver->query( 'SELECT DATABASE()' )->fetch()[0] );
6161

6262
// DSN with two semicolons in the database name.
63-
$driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=w;;;;p' );
63+
$driver = new WP_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=w;;;;p' );
6464
$this->assertSame( 'w;;p', $driver->query( 'SELECT DATABASE()' )->fetch()[0] );
6565

6666
// DSN with a "\0" byte (always terminates the DSN string).
67-
$driver = new WP_PDO_MySQL_On_SQLite( "mysql-on-sqlite:path=:memory:;dbname=w\0p;" );
67+
$driver = new WP_MySQL_On_SQLite( "mysql-on-sqlite:path=:memory:;dbname=w\0p;" );
6868
$this->assertSame( 'w', $driver->query( 'SELECT DATABASE()' )->fetch()[0] );
6969
}
7070

@@ -73,7 +73,7 @@ public function test_journal_mode_defaults_to_wal(): void {
7373
unlink( $path );
7474

7575
try {
76-
$driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=' . $path . ';dbname=wp' );
76+
$driver = new WP_MySQL_On_SQLite( 'mysql-on-sqlite:path=' . $path . ';dbname=wp' );
7777
$connection = $driver->get_connection();
7878
$this->assertSame(
7979
'wal',
@@ -93,7 +93,7 @@ public function test_journal_mode_and_synchronous_driver_options(): void {
9393
unlink( $path );
9494

9595
try {
96-
$driver = new WP_PDO_MySQL_On_SQLite(
96+
$driver = new WP_MySQL_On_SQLite(
9797
'mysql-on-sqlite:path=' . $path . ';dbname=wp',
9898
null,
9999
null,

packages/mysql-on-sqlite/tests/WP_SQLite_Driver_Query_Tests.php renamed to packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Query_Tests.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
/**
8787
* Unit tests using the WordPress table definitions.
8888
*/
89-
class WP_SQLite_Driver_Query_Tests extends TestCase {
90-
/** @var WP_PDO_MySQL_On_SQLite */
89+
class WP_MySQL_On_SQLite_Query_Tests extends TestCase {
90+
/** @var WP_MySQL_On_SQLite */
9191
private $engine;
9292

9393
/** @var PDO */
@@ -109,7 +109,7 @@ public function setUp(): void {
109109

110110
$pdo_class = PHP_VERSION_ID >= 80400 ? PDO\SQLite::class : PDO::class;
111111
$this->sqlite = new $pdo_class( 'sqlite::memory:' );
112-
$this->engine = new WP_PDO_MySQL_On_SQLite(
112+
$this->engine = new WP_MySQL_On_SQLite(
113113
'mysql-on-sqlite:dbname=wp',
114114
null,
115115
null,

0 commit comments

Comments
 (0)