Skip to content

Commit b832938

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 6446c5a commit b832938

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
@@ -884,6 +884,31 @@ function ( string $sql, array $params ) {
884884
}
885885
}
886886

887+
/**
888+
* PDO API: Prepare a MySQL statement for execution.
889+
*
890+
* Prepared statements are not implemented yet. Report the standard PDO
891+
* unsupported-function diagnostic instead of using uninitialized parent
892+
* PDO state.
893+
*
894+
* @param string $query The MySQL statement to prepare.
895+
* @param array|null $options Optional statement options.
896+
* @return PDOStatement|false False when exceptions are disabled.
897+
*
898+
* @throws WP_MySQL_On_SQLite_Exception When exception mode is enabled.
899+
*/
900+
#[ReturnTypeWillChange]
901+
public function prepare( $query, $options = null ) {
902+
$driver_message = 'driver does not support prepared statements';
903+
$exception = $this->new_driver_exception(
904+
'SQLSTATE[IM001]: Driver does not support this function: ' . $driver_message,
905+
'IM001',
906+
null,
907+
array( 'IM001', 0, $driver_message )
908+
);
909+
return $this->handle_pdo_error( $exception );
910+
}
911+
887912
/**
888913
* PDO API: Translate and execute a MySQL query in SQLite.
889914
*

0 commit comments

Comments
 (0)