Skip to content

Commit a207d1e

Browse files
committed
Preserve wpdb type during metadata lookup
Restore the previous is_mysql value after column charset and length lookups, treating an unset flag as null.
1 parent ecd8437 commit a207d1e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-db.php‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public function set_charset( $dbh, $charset = null, $collate = null ) {
9191
* no character set. WP_Error object on failure.
9292
*/
9393
public function get_col_charset( $table, $column ) {
94+
$original_is_mysql = $this->is_mysql ?? null;
95+
9496
/*
9597
* The parent method returns early when `$this->is_mysql` is falsy.
9698
* Since SQLite doesn't set this flag, we enable it temporarily so
@@ -102,7 +104,7 @@ public function get_col_charset( $table, $column ) {
102104
$this->is_mysql = true;
103105
return parent::get_col_charset( $table, $column );
104106
} finally {
105-
$this->is_mysql = null;
107+
$this->is_mysql = $original_is_mysql;
106108
}
107109
}
108110

@@ -120,12 +122,14 @@ public function get_col_charset( $table, $column ) {
120122
* no length. WP_Error object on failure.
121123
*/
122124
public function get_col_length( $table, $column ) {
125+
$original_is_mysql = $this->is_mysql ?? null;
126+
123127
// See get_col_charset() for an explanation of the is_mysql flag.
124128
try {
125129
$this->is_mysql = true;
126130
return parent::get_col_length( $table, $column );
127131
} finally {
128-
$this->is_mysql = null;
132+
$this->is_mysql = $original_is_mysql;
129133
}
130134
}
131135

0 commit comments

Comments
 (0)