Skip to content

Commit 3b202b6

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 26e02f8 commit 3b202b6

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
@@ -84,6 +84,8 @@ public function set_charset( $dbh, $charset = null, $collate = null ) {
8484
* no character set. WP_Error object on failure.
8585
*/
8686
public function get_col_charset( $table, $column ) {
87+
$original_is_mysql = $this->is_mysql ?? null;
88+
8789
/*
8890
* The parent method returns early when `$this->is_mysql` is falsy.
8991
* Since SQLite doesn't set this flag, we enable it temporarily so
@@ -95,7 +97,7 @@ public function get_col_charset( $table, $column ) {
9597
$this->is_mysql = true;
9698
return parent::get_col_charset( $table, $column );
9799
} finally {
98-
$this->is_mysql = null;
100+
$this->is_mysql = $original_is_mysql;
99101
}
100102
}
101103

@@ -113,12 +115,14 @@ public function get_col_charset( $table, $column ) {
113115
* no length. WP_Error object on failure.
114116
*/
115117
public function get_col_length( $table, $column ) {
118+
$original_is_mysql = $this->is_mysql ?? null;
119+
116120
// See get_col_charset() for an explanation of the is_mysql flag.
117121
try {
118122
$this->is_mysql = true;
119123
return parent::get_col_length( $table, $column );
120124
} finally {
121-
$this->is_mysql = null;
125+
$this->is_mysql = $original_is_mysql;
122126
}
123127
}
124128

0 commit comments

Comments
 (0)