Skip to content

Commit 6e83c19

Browse files
committed
Fix warnings on site health screen
Information schema subqueries need to provide the actual database name, so that parent queries that compare against it return some data. Fixes: Warning: Undefined array key "wp_comments" in /var/www/html/wp-admin/includes/class-wp-site-health.php on line 3586 Warning: Attempt to read property "rows" on null in /var/www/html/wp-admin/includes/class-wp-site-health.php on line 3586 Warning: Undefined array key "wp_options" in /var/www/html/wp-admin/includes/class-wp-site-health.php on line 3586 Warning: Attempt to read property "rows" on null in /var/www/html/wp-admin/includes/class-wp-site-health.php on line 3586 Warning: Undefined array key "wp_posts" in /var/www/html/wp-admin/includes/class-wp-site-health.php on line 3586 Warning: Attempt to read property "rows" on null in /var/www/html/wp-admin/includes/class-wp-site-health.php on line 3586 Warning: Undefined array key "wp_terms" in /var/www/html/wp-admin/includes/class-wp-site-health.php on line 3586 Warning: Attempt to read property "rows" on null in /var/www/html/wp-admin/includes/class-wp-site-health.php on line 3586 Warning: Undefined array key "wp_users" in /var/www/html/wp-admin/includes/class-wp-site-health.php on line 3586 Warning: Attempt to read property "rows" on null in /var/www/html/wp-admin/includes/class-wp-site-health.php on line 3586
1 parent 4074c52 commit 6e83c19

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: tests/WP_SQLite_Metadata_Tests.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testInformationSchemaTables() {
7878
$this->assertEquals(
7979
array(
8080
'TABLE_CATALOG' => 'def',
81-
'TABLE_SCHEMA' => 'database',
81+
'TABLE_SCHEMA' => '',
8282
'TABLE_NAME' => 'wp_options',
8383
'TABLE_TYPE' => 'BASE TABLE',
8484
'ENGINE' => 'InnoDB',

Diff for: wp-includes/sqlite/class-wp-sqlite-translator.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -1528,14 +1528,16 @@ private function execute_select() {
15281528

15291529
if ( $table_name && str_starts_with( strtolower( $table_name ), 'information_schema' ) ) {
15301530
$this->is_information_schema_query = true;
1531-
$updated_query = preg_replace(
1531+
1532+
$database_name = $this->pdo->quote( defined( 'DB_NAME' ) ? DB_NAME : '' );
1533+
$updated_query = preg_replace(
15321534
'/' . $table_name . '\.tables/i',
15331535
/**
15341536
* TODO: Return real values for hardcoded column values.
15351537
*/
15361538
"(SELECT
15371539
'def' as TABLE_CATALOG,
1538-
'database' as TABLE_SCHEMA,
1540+
$database_name as TABLE_SCHEMA,
15391541
name as TABLE_NAME,
15401542
CASE type
15411543
WHEN 'table' THEN 'BASE TABLE'

0 commit comments

Comments
 (0)