[wp-trac] [WordPress Trac] #64908: PHP Warnings in Site Health information copy button (was: WordPress Core Warnings in Site Health (PHP 8.5.4 Compatibility Issue))
WordPress Trac
noreply at wordpress.org
Fri Mar 20 00:26:56 UTC 2026
#64908: PHP Warnings in Site Health information copy button
--------------------------+------------------------------------------------
Reporter: tunyk | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Site Health | Version: 6.9.4
Severity: normal | Resolution:
Keywords: | Focuses: administration, php-compatibility
--------------------------+------------------------------------------------
Comment (by sabernhardt):
`WP_Debug_Data::format()` expects that `$field['label']` and
`$field['value']` are set because both the label and value are required.
Query Monitor seems to indicate 3 items missing a value and 1 missing a
label on your site. The copy-to-clipboard button has `esc_attr()`, but
that does not escape a PHP error right now.
I was able to force the error in PHP 8.2.26 and WordPress trunk by
intentionally unsetting both `$field['debug']` and `$field['value']` when
the value matched the version number of my active theme.
{{{
if(isset($field['value'])&&'4.1'===$field['value']){unset($field['debug']);unset($field['value']);}
}}}
To determine where the missing values are, the class could check `isset(
$field['value'] )` before using it and return a message if it is not set:
{{{
if ( 'debug' === $data_type && isset( $field['debug'] ) ) {
$debug_data = $field['debug'];
} elseif ( isset( $field['value'] ) ) {
$debug_data = $field['value'];
} else {
$debug_data = 'Missing value in ' . __METHOD__ . '()';
}
}}}
(And the `$label` variable could have a similar condition for a missing
`$field['label']`, but that does not affect the button.)
If the copy-to-clipboard button is the main issue for core to fix, then
`site-health-info.php` could fetch the data before inserting it into the
attribute:
{{{
<?php $clipboard_text = WP_Debug_Data::format( $info, 'debug' ); ?>
<div class="site-health-copy-buttons">
<div class="copy-button-wrapper">
<button type="button" class="button copy-button" data-
clipboard-text="<?php echo esc_attr( $clipboard_text ); ?>">
<?php _e( 'Copy site info to clipboard' ); ?>
</button>
<span class="success hidden" aria-hidden="true"><?php _e(
'Copied!' ); ?></span>
</div>
</div>
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64908#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list