Skip to content

Expand PDO API coverage - #471

Draft
JanJakes wants to merge 10 commits into
removalsfrom
pdo-coverage
Draft

Expand PDO API coverage#471
JanJakes wants to merge 10 commits into
removalsfrom
pdo-coverage

Conversation

@JanJakes

@JanJakes JanJakes commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

Stacked on #469.

This expands PDO compatibility for WP_MySQL_On_SQLite before 3.0 by covering connection diagnostics, constructor options, result statements, column metadata, and PHP 8.4's connection factory. Prepared statements now fail through standard PDO diagnostics until parameter binding can be implemented safely across the full translation pipeline.

  • Implement lastInsertId(), errorCode(), and errorInfo() without relying on uninitialized parent PDO state.
  • Isolate the public last insert ID from internal information-schema writes.
  • Honor numeric PDO constructor options, including fetch, stringification, persistence, and error modes, while keeping internal SQLite operations exception-safe.
  • Initialize PDOStatement::$queryString and delegate safe result-statement methods including iteration, closeCursor(), bindColumn(), nextRowset(), diagnostics, and debugDumpParams().
  • Snapshot result column metadata into each statement, implement getColumnMeta() with its array|false contract, and migrate the WordPress and MySQL proxy consumers.
  • Deprecate the stateful get_last_column_count() and get_last_column_meta() compatibility methods.
  • Populate PDOException::$errorInfo with native SQLite or emulated MySQL diagnostics.
  • Override PDO::connect() on PHP 8.4+ so it creates the emulated connection.
  • Report prepare() as unsupported with SQLSTATE IM001, respecting the configured PDO error mode instead of triggering an uninitialized-object error.

@JanJakes
JanJakes force-pushed the pdo-coverage branch 6 times, most recently from 01db6d5 to 2bd2721 Compare August 4, 2026 19:03
Expose generated IDs through PDO::lastInsertId(), retain integer conversion in the legacy facade, and migrate direct consumers to the PDO API.
@JanJakes JanJakes mentioned this pull request Aug 4, 2026
8 tasks
*
* @return int|string
*/
public function get_insert_id() {

@JanJakes JanJakes Aug 5, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Searches: Veloria, GitHub.

The only external consumer is Automattic/markdown-database-integration, which we can help handle. The deprecated WP_SQLite_Driver facade retains get_insert_id() for legacy consumers.

* @throws PDOException When the query execution fails.
* @return PDOStatement The PDO statement object.
*/
public function get_last_column_count(): int {

@JanJakes JanJakes Aug 5, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Searches: Veloria, GitHub.

No external consumers call these methods directly on WP_MySQL_On_SQLite. The deprecated WP_SQLite_Driver facade retains them, while PDO consumers use PDOStatement::columnCount() and PDOStatement::getColumnMeta().

Snapshot IDs produced by user INSERT and REPLACE statements so internal information-schema writes cannot alter PDO and legacy driver results.
Treat direct transaction calls as independent operations so insert IDs and SQLite query traces do not leak across operation boundaries.
Initialize the original MySQL query string and delegate supported result-oriented PDOStatement operations to the wrapped SQLite statement.
Preserve native PDO diagnostics and provide MySQL-compatible SQLSTATE, vendor code, and message tuples for emulated errors.
Track driver diagnostics and honor PDO::ATTR_ERRMODE for query() and exec() while keeping the underlying SQLite connection in exception mode.
Accept null options, pass numeric attributes to new SQLite connections, and apply caller-visible attributes through the wrapper.
Override PDO::connect() on PHP 8.4 and newer while loading an empty compatibility trait on older supported runtimes.
Return the standard IM001 PDO diagnostic according to the configured error mode instead of invoking uninitialized parent PDO state.
Snapshot raw result metadata into each PDO statement, resolve and cache MySQL-compatible metadata lazily, and migrate consumers away from mutable driver-wide last-query metadata. Preserve the legacy metadata getters only on the deprecated WP_SQLite_Driver facade.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant