query-monitor
query-monitor copied to clipboard
fix $row['ltime'] Undefined index
fix $row['ltime'] Undefined index
Thanks for the PR!
Can you let me know how to reproduce the problem please? It looks like the underlying problem might lie elsewhere, because that ltime
element should always be present.
Thanks for the PR!
Can you let me know how to reproduce the problem please? It looks like the underlying problem might lie elsewhere, because that
ltime
element should always be present.
[04-Jun-2019 11:14:16 UTC] PHP Notice: Undefined index: ltime in /wp-content/plugins/query-monitor/output/html/http.php on line 51
[04-Jun-2019 11:14:16 UTC] PHP Stack trace:
[04-Jun-2019 11:14:16 UTC] PHP 1. shutdown_action_hook() /wp-includes/load.php:0
[04-Jun-2019 11:14:16 UTC] PHP 2. do_action() /wp-includes/load.php:954
[04-Jun-2019 11:14:16 UTC] PHP 3. WP_Hook->do_action() /wp-includes/plugin.php:465
[04-Jun-2019 11:14:16 UTC] PHP 4. WP_Hook->apply_filters() /wp-includes/class-wp-hook.php:310
[04-Jun-2019 11:14:16 UTC] PHP 5. QM_Dispatcher_Html->dispatch() /wp-includes/class-wp-hook.php:286
[04-Jun-2019 11:14:16 UTC] PHP 6. QM_Output_Html_HTTP->output() /wp-content/plugins/query-monitor/dispatchers/Html.php:197
----------
[04-Jun-2019 11:14:16 UTC] PHP Notice: Trying to get property 'name' of non-object in /wp-content/plugins/query-monitor/output/html/http.php on line 134
[04-Jun-2019 11:14:16 UTC] PHP Stack trace:
[04-Jun-2019 11:14:16 UTC] PHP 1. shutdown_action_hook() /wp-includes/load.php:0
[04-Jun-2019 11:14:16 UTC] PHP 2. do_action() /wp-includes/load.php:954
[04-Jun-2019 11:14:16 UTC] PHP 3. WP_Hook->do_action() /wp-includes/plugin.php:465
[04-Jun-2019 11:14:16 UTC] PHP 4. WP_Hook->apply_filters() /wp-includes/class-wp-hook.php:310
[04-Jun-2019 11:14:16 UTC] PHP 5. QM_Dispatcher_Html->dispatch() /wp-includes/class-wp-hook.php:286
[04-Jun-2019 11:14:16 UTC] PHP 6. QM_Output_Html_HTTP->output() /wp-content/plugins/query-monitor/dispatchers/Html.php:197
Maybe helpful.
I'm seeing this and many more similar errors. It seems to be related to
$data = $this->collector->get_data();
and
foreach ( $data['http'] as $key => $row )
On my end it seems that $row
is missing many elements and also $component
is missing elements.
The following errors repeat. I don't yet know how to replicate.
[02-Jan-2020 22:01:36 UTC] PHP Notice Undefined index: ltime in /sites/tribe.thefragens.net/files/wp-content/plugins/query-monitor/output/html/http.php on line 73
[02-Jan-2020 22:01:36 UTC] PHP Notice Undefined index: component in /sites/tribe.thefragens.net/files/wp-content/plugins/query-monitor/output/html/http.php on line 119
[02-Jan-2020 22:01:36 UTC] PHP Notice Trying to get property 'name' of non-object in /sites/tribe.thefragens.net/files/wp-content/plugins/query-monitor/output/html/http.php on line 156
[02-Jan-2020 22:01:36 UTC] PHP Notice Undefined index: type in /sites/tribe.thefragens.net/files/wp-content/plugins/query-monitor/output/html/http.php on line 157
[02-Jan-2020 22:01:36 UTC] PHP Notice Undefined index: ltime in /sites/tribe.thefragens.net/files/wp-content/plugins/query-monitor/output/html/http.php on line 158
[02-Jan-2020 22:01:36 UTC] PHP Notice Trying to get property 'context' of non-object in /sites/tribe.thefragens.net/files/wp-content/plugins/query-monitor/output/html/http.php on line 160
[02-Jan-2020 22:01:36 UTC] PHP Notice Trying to get property 'name' of non-object in /sites/tribe.thefragens.net/files/wp-content/plugins/query-monitor/output/html/http.php on line 292
I just figured out how to trigger this. Purge the object cache. My site has a redis cache and purging it consistently causes these errors.
In my case an early exit from the foreach
loop works best.
foreach ( $data['http'] as $key => $row ) {
if ( ! isset( $row['ltime'], $row['component'] ) ) {
continue;
}
$ltime = $row['ltime'];
$i++;
$is_error = false;
$row_attr = array();
$css = '';
...