Skip to content

Commit 3e79b56

Browse files
committed
Rename the statement implementation
Align the concrete statement class with the WP_MySQL_On_SQLite API name and replace the obsolete proxy terminology. Do not retain an alias because public code searches found no external dependency on the old class name.
1 parent 75341f6 commit 3e79b56

5 files changed

Lines changed: 23 additions & 12 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
require_once __DIR__ . '/sqlite/class-wp-sqlite-information-schema-reconstructor.php';
4343
require_once __DIR__ . '/sqlite/class-wp-sqlite-pdo-user-defined-functions.php';
4444
require_once __DIR__ . '/sqlite/class-wp-mysql-on-sqlite.php';
45-
require_once __DIR__ . '/sqlite/class-wp-pdo-proxy-statement.php';
45+
require_once __DIR__ . '/sqlite/class-wp-mysql-on-sqlite-statement.php';

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626
* we conditionally define traits with different APIs based on the PHP version.
2727
*/
2828
if ( PHP_VERSION_ID < 80000 ) {
29-
trait WP_PDO_Proxy_Statement_PHP_Compat {
29+
/**
30+
* PHP compatibility methods for WP_MySQL_On_SQLite_Statement.
31+
*
32+
* @access private
33+
*/
34+
trait WP_MySQL_On_SQLite_Statement_PHP_Compat {
3035
/**
3136
* Set the default fetch mode for this statement.
3237
*
@@ -61,7 +66,12 @@ public function fetchAll( $mode = null, $class_name = null, $constructor_args =
6166
}
6267
}
6368
} else {
64-
trait WP_PDO_Proxy_Statement_PHP_Compat {
69+
/**
70+
* PHP compatibility methods for WP_MySQL_On_SQLite_Statement.
71+
*
72+
* @access private
73+
*/
74+
trait WP_MySQL_On_SQLite_Statement_PHP_Compat {
6575
/**
6676
* Set the default fetch mode for this statement.
6777
*
@@ -88,10 +98,10 @@ public function fetchAll( $mode = PDO::FETCH_DEFAULT, ...$args ): array {
8898
}
8999

90100
/**
91-
* PDOStatement implementation that operates on in-memory data.
101+
* PDOStatement implementation for MySQL-on-SQLite query results.
92102
*
93-
* This class implements a complete PDOStatement interface on top of PHP arrays.
94-
* It is used for result sets that are composed or transformed in the PHP layer.
103+
* Delegates operations to the underlying SQLite statement while adapting
104+
* MySQL-specific behavior such as affected row counts.
95105
*
96106
* PDO supports the following fetch modes:
97107
* - PDO::FETCH_DEFAULT: current default fetch mode (available from PHP 8.0)
@@ -108,8 +118,8 @@ public function fetchAll( $mode = PDO::FETCH_DEFAULT, ...$args ): array {
108118
* - PDO::FETCH_BOUND: bind values to PHP variables, can't be used with fetchAll()
109119
* - PDO::FETCH_FUNC: custom function, only works with fetchAll(), can't be default [1 extra arg]
110120
*/
111-
class WP_PDO_Proxy_Statement extends PDOStatement {
112-
use WP_PDO_Proxy_Statement_PHP_Compat;
121+
class WP_MySQL_On_SQLite_Statement extends PDOStatement {
122+
use WP_MySQL_On_SQLite_Statement_PHP_Compat;
113123

114124
/**
115125
* The original PDO statement.
@@ -347,7 +357,7 @@ public function debugDumpParams(): ?bool {
347357
/**
348358
* Fetch all remaining rows from the result set.
349359
*
350-
* This is used internally by the "WP_PDO_Proxy_Statement_PHP_Compat" trait,
360+
* This is used internally by the "WP_MySQL_On_SQLite_Statement_PHP_Compat" trait,
351361
* that is defined conditionally based on the current PHP version.
352362
*
353363
* @param int $mode The fetch mode to use.
@@ -361,7 +371,7 @@ private function fetchAllRows( $mode = null, ...$args ): array {
361371
/**
362372
* Set the default fetch mode for this statement.
363373
*
364-
* This is used internally by the "WP_PDO_Proxy_Statement_PHP_Compat" trait,
374+
* This is used internally by the "WP_MySQL_On_SQLite_Statement_PHP_Compat" trait,
365375
* that is defined conditionally based on the current PHP version.
366376
*
367377
* @param int $mode The fetch mode to set as the default.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ public function query( string $query, ?int $fetch_mode = null, ...$fetch_mode_ar
10371037
$this->last_result_statement = $this->create_result_statement_from_data( array(), array() );
10381038
}
10391039

1040-
$stmt = new WP_PDO_Proxy_Statement( $this->last_result_statement, $this->last_affected_rows );
1040+
$stmt = new WP_MySQL_On_SQLite_Statement( $this->last_result_statement, $this->last_affected_rows );
10411041
$stmt->setFetchMode( $fetch_mode, ...$fetch_mode_args );
10421042
return $stmt;
10431043
} catch ( Throwable $e ) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* (e.g., WP CLI SQLite Command), ensure the PDO-based classes are loaded.
1111
*/
1212
require_once __DIR__ . '/class-wp-mysql-on-sqlite.php';
13-
require_once __DIR__ . '/class-wp-pdo-proxy-statement.php';
13+
require_once __DIR__ . '/class-wp-mysql-on-sqlite-statement.php';
1414

1515
/**
1616
* Deprecated: A proxy of the WP_MySQL_On_SQLite class preserving the legacy API.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public function test_journal_mode_and_synchronous_driver_options(): void {
137137

138138
public function test_query(): void {
139139
$result = $this->driver->query( "SELECT 1, 'abc'" );
140+
$this->assertInstanceOf( WP_MySQL_On_SQLite_Statement::class, $result );
140141
$this->assertInstanceOf( PDOStatement::class, $result );
141142
if ( PHP_VERSION_ID < 80000 ) {
142143
$this->assertSame(

0 commit comments

Comments
 (0)