Skip to content

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented Sep 5, 2025

Fixes #2158

This addresses issues which may arise when using a database implementation which doesn't construct $wpdb->queries in the same way as core does, namely when a logged query is not an indexed array or it it doesn't have a float at index 1. This can happen when using a custom save_query_callback in HyperDB, for example. This essentially builds upon the existing type checking for odd database implementations which don't define $wpdb->queries. In both cases, notices are now emitted before aborting.

If $wpdb->queries is absent or not an array, this notice is emitted:

perflab_register_default_server_timing_before_template_metrics(): Unable to compute server timing for "before-template-db-queries" because $wpdb->queries is not an array.

If a saved query array doesn't have the expected elapsed time as the second argument, then this notice is emitted:

perflab_register_default_server_timing_before_template_metrics(): Unable to compute server timing for "before-template-db-queries" because a saved query in $wpdb->queries lacks the elapsed time as the second array value.

Otherwise, if all is good, then the before-template-db-queries server timing entry is sent:

Screenshot 2025-09-04 at 18 02 07

@westonruter westonruter added this to the performance-lab n.e.x.t milestone Sep 5, 2025
@westonruter westonruter added [Type] Bug An existing feature is broken [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only labels Sep 5, 2025
@westonruter

This comment was marked as outdated.

@github-actions
Copy link

github-actions bot commented Sep 5, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: westonruter <[email protected]>
Co-authored-by: adamsilverstein <[email protected]>
Co-authored-by: emrikol <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

❌ Patch coverage is 2.50000% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.54%. Comparing base (01a0027) to head (4a8aa77).
⚠️ Report is 74 commits behind head on trunk.

Files with missing lines Patch % Lines
...erformance-lab/includes/server-timing/defaults.php 2.50% 39 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk    #2159      +/-   ##
==========================================
- Coverage   68.81%   68.54%   -0.27%     
==========================================
  Files          90       90              
  Lines        8006     8037      +31     
==========================================
  Hits         5509     5509              
- Misses       2497     2528      +31     
Flag Coverage Δ
multisite 68.54% <2.50%> (-0.27%) ⬇️
single 35.33% <2.50%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@westonruter
Copy link
Member Author

Build for testing: performance-lab.zip

@westonruter
Copy link
Member Author

PR fixes issue in testing: #2158 (comment)

Copy link
Member

@adamsilverstein adamsilverstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good!

@westonruter westonruter merged commit 4db03c2 into trunk Sep 24, 2025
25 of 26 checks passed
@westonruter westonruter deleted the fix/server-timing-for-db-queries branch September 24, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Type] Bug An existing feature is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance Lab: PHP Warning: "Undefined array key 1"

3 participants