FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add notices and improved type checking for `$wpdb->queries` when attempting to compute server-timing for database queries by westonruter · Pull Request #2159 · WordPress/performance · GitHub

Add notices and improved type checking for $wpdb->queries when attempting to compute server-timing for database queries - #2159

Merged
westonruter merged 3 commits into
trunkfrom
fix/server-timing-for-db-queries
Sep 24, 2025
Merged

Add notices and improved type checking for $wpdb->queries when attempting to compute server-timing for database queries#2159
westonruter merged 3 commits into
trunkfrom
fix/server-timing-for-db-queries

Conversation

westonruter commented Sep 5, 2025
edited
Loading

Copy link
Copy Markdown
Member

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:

westonruter added this to the performance-lab n.e.x.t milestone Sep 5, 2025
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

This comment was marked as outdated.

github-actions Bot commented Sep 5, 2025
edited
Loading

Copy link
Copy Markdown

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 <westonruter@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: emrikol <emrikol@git.wordpress.org>

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

codecov Bot commented Sep 5, 2025
edited
Loading

Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Member Author

Build for testing: performance-lab.zip

Copy link
Copy Markdown
Member Author

PR fixes issue in testing: #2158 (comment)

adamsilverstein left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Code looks good!

westonruter merged commit 4db03c2 into trunk Sep 24, 2025
25 of 26 checks passed
westonruter deleted the fix/server-timing-for-db-queries branch September 24, 2025 17:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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"

2 participants


Back | FazBrowse Home | New Git URL