Skip to content

Commit c35b4a2

Browse files
committed
Report prepared statements as unsupported
Return the standard IM001 PDO diagnostic according to the configured error mode instead of invoking uninitialized parent PDO state.
1 parent 6141a56 commit c35b4a2

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,31 @@ function ( string $sql, array $params ) {
944944
}
945945
}
946946

947+
/**
948+
* PDO API: Prepare a MySQL statement for execution.
949+
*
950+
* Prepared statements are not implemented yet. Report the standard PDO
951+
* unsupported-function diagnostic instead of using uninitialized parent
952+
* PDO state.
953+
*
954+
* @param string $query The MySQL statement to prepare.
955+
* @param array|null $options Optional statement options.
956+
* @return PDOStatement|false False when exceptions are disabled.
957+
*
958+
* @throws WP_MySQL_On_SQLite_Exception When exception mode is enabled.
959+
*/
960+
#[ReturnTypeWillChange]
961+
public function prepare( $query, $options = null ) {
962+
$driver_message = 'driver does not support prepared statements';
963+
$exception = $this->new_driver_exception(
964+
'SQLSTATE[IM001]: Driver does not support this function: ' . $driver_message,
965+
'IM001',
966+
null,
967+
array( 'IM001', 0, $driver_message )
968+
);
969+
return $this->handle_pdo_error( $exception );
970+
}
971+
947972
/**
948973
* PDO API: Translate and execute a MySQL query in SQLite.
949974
*

0 commit comments

Comments
 (0)