Skip to content

Commit ecd8437

Browse files
committed
Delegate wpdb capability checks
Handle only the MySQL-client-specific utf8mb4 capability in the SQLite override and defer all other capabilities to WordPress. This restores identifier placeholders and database-version-based utf8mb4_520 detection.
1 parent ccb3ef0 commit ecd8437

2 files changed

Lines changed: 12 additions & 23 deletions

File tree

‎.github/workflows/wp-tests-phpunit-run.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ const expectedFailures = [
6767
'Tests_DB_Charset::test_strip_invalid_text_for_column_bails_if_ascii_input_too_long',
6868
'Tests_DB_dbDelta::test_spatial_indices',
6969
'Tests_DB::test_delete_value_too_long_for_field with data set "too long"',
70-
'Tests_DB::test_has_cap',
7170
'Tests_DB::test_insert_value_too_long_for_field with data set "too long"',
7271
'Tests_DB::test_mysqli_flush_sync',
7372
'Tests_DB::test_pre_get_col_charset_filter',
@@ -76,7 +75,6 @@ const expectedFailures = [
7675
'Tests_DB::test_query_value_contains_invalid_chars',
7776
'Tests_DB::test_replace_value_too_long_for_field with data set "too long"',
7877
'Tests_DB::test_replace',
79-
'Tests_DB::test_supports_collation',
8078
'Tests_DB::test_update_value_too_long_for_field with data set "too long"',
8179
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #1',
8280
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #2',

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

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -728,33 +728,20 @@ protected function load_col_info() {
728728
/**
729729
* Determines whether the database supports a given feature.
730730
*
731-
* This overrides wpdb::has_cap() while closely mirroring its implementation.
732-
* The override is needed because the parent's 'utf8mb4' capability check calls
733-
* mysqli_get_client_info(), which is environment-dependent and not applicable
734-
* for SQLite.
731+
* The utf8mb4 check is handled here because older WordPress versions inspect
732+
* the MySQL client library. All other capabilities use the parent logic.
735733
*
736734
* @see wpdb::has_cap()
737735
*
738-
* @param string $db_cap The feature to check for. Accepts 'collation',
739-
* 'group_concat', 'subqueries', 'set_charset',
740-
* 'utf8mb4', or 'utf8mb4_520'.
741-
* @return bool Whether the database feature is supported, false otherwise.
736+
* @param string $db_cap The feature to check for.
737+
* @return bool True when the database feature is supported, false otherwise.
742738
*/
743739
public function has_cap( $db_cap ) {
744-
$db_cap = strtolower( $db_cap );
745-
746-
switch ( $db_cap ) {
747-
case 'collation':
748-
case 'group_concat':
749-
case 'subqueries':
750-
case 'set_charset':
751-
case 'utf8mb4':
752-
return true;
753-
case 'utf8mb4_520':
754-
return version_compare( $GLOBALS['wp_version'], '4.6', '>=' );
740+
if ( 'utf8mb4' === strtolower( $db_cap ) ) {
741+
return true;
755742
}
756743

757-
return false;
744+
return parent::has_cap( $db_cap );
758745
}
759746

760747
/**
@@ -773,9 +760,13 @@ public function db_version() {
773760
/**
774761
* Returns the version of the SQLite engine.
775762
*
776-
* @return string SQLite engine version as a string.
763+
* @return string SQLite engine version, or an empty string while disconnected.
777764
*/
778765
public function db_server_info() {
766+
if ( ! $this->dbh ) {
767+
return '';
768+
}
769+
779770
return $this->dbh->get_sqlite_version();
780771
}
781772

0 commit comments

Comments
 (0)