Skip to content

Commit fc5ed4e

Browse files
JanJakesbgrgicak
authored andcommitted
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 a179777 commit fc5ed4e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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',

wp-includes/sqlite/class-wp-sqlite-translator.php

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

15201520
if ( $table_name && str_starts_with( strtolower( $table_name ), 'information_schema' ) ) {
15211521
$this->is_information_schema_query = true;
1522-
$updated_query = preg_replace(
1522+
1523+
$database_name = $this->pdo->quote( defined( 'DB_NAME' ) ? DB_NAME : '' );
1524+
$updated_query = preg_replace(
15231525
'/' . $table_name . '\.tables/i',
15241526
/**
15251527
* TODO: Return real values for hardcoded column values.
15261528
*/
15271529
"(SELECT
15281530
'def' as TABLE_CATALOG,
1529-
'database' as TABLE_SCHEMA,
1531+
$database_name as TABLE_SCHEMA,
15301532
name as TABLE_NAME,
15311533
CASE type
15321534
WHEN 'table' THEN 'BASE TABLE'

0 commit comments

Comments
 (0)