Skip to content

Commit d69867f

Browse files
committed
Fix broken error handling in sqlite_make_db_sqlite()
The catch block accessed $err->errorInfo[1] and $err->errorInfo[2], but WP_SQLite_Driver_Exception (which extends PDOException) never sets the errorInfo property — it is only populated by PHP's internal PDO C code, not when constructing PDOException subclasses in userland. This caused PHP warnings and a blank error message on installation failures. Use $err->getMessage() instead, which is always available, and remove the unused $err_code variable. Made-with: Cursor
1 parent 1437789 commit d69867f

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

packages/plugin-sqlite-database-integration/wp-includes/sqlite/install-functions.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,12 @@ function sqlite_make_db_sqlite() {
5252
}
5353
$translator->commit();
5454
} catch ( PDOException $err ) {
55-
$err_data = $err->errorInfo; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
56-
$err_code = $err_data[1];
5755
$translator->rollback();
5856
$message = sprintf(
5957
'Error occurred while creating tables or indexes...<br />Query was: %s<br />',
6058
var_export( $query, true )
6159
);
62-
$message .= sprintf( 'Error message is: %s', $err_data[2] );
60+
$message .= sprintf( 'Error message is: %s', $err->getMessage() );
6361
wp_die( $message, 'Database Error!' );
6462
}
6563

0 commit comments

Comments
 (0)