Query Monitor – The developer tools panel for WordPress

描述

Query Monitor 是 WordPress 的开发人员工具面板。它可以调试数据库查询、PHP 错误、挂钩和操作、块编辑器块、排队脚本和样式表、HTTP API 调用等。

它包括一些高级功能,例如 Ajax 调用调试、REST API 调用、用户能力检查以及对块主题和完整站点编辑的完全支持。它包括通过插件或主题缩小大部分输出范围的能力,使您可以快速确定性能不佳的插件、主题或功能。

查询监视器重点关注以有用的方式呈现其信息,例如通过显示按负责它们的插件、主题或函数分组的聚合数据库查询。它添加了一个管理工具栏菜单,显示当前页面的概述,一旦您选择菜单项,面板中就会显示完整的调试信息。

Query Monitor 支持最多三年前的 WordPress 版本以及 PHP 7.4 或更高版本。

有关完整信息,请参阅Query Monitor 网站

以下是每个页面加载所显示内容的概述:

  • 数据库查询,包括缓慢、重复或错误查询的通知。允许按查询类型(SELECTUPDATEDELETE 等)、负责组件(插件、主题、WordPress 核心)和调用函数进行过滤,并为每个提供单独的聚合视图。
  • 模板文件名、完整的模板层次结构以及已加载或未加载的所有模板部分的名称(对于块主题和经典主题)。
  • PHP 错误及其负责的组件和调用堆栈以及管理工具栏中的可见警告都很好地呈现。
  • 在您网站的代码中使用“做错了”或“已弃用”功能。
  • 帖子内容和完整站点编辑 (FSE) 中的块和关联属性。
  • 匹配的重写规则、关联的查询字符串和查询变量。
  • 排队的脚本和样式表,以及它们的依赖项、依赖项以及损坏的依赖项的警报。
  • 每个文本域的语言设置和加载的翻译文件(MO 文件和 JSON 文件)。
  • HTTP API 请求,包含响应代码、负责的组件和所用时间,以及失败或错误请求的警报。
  • 用户能力检查,以及结果和传递给能力检查的任何参数。
  • 环境信息,包括有关 PHP、数据库、WordPress 和 Web 服务器的详细信息。
  • 所有 WordPress 条件函数的值,例如 is_single()is_home() 等。
  • 已更新的瞬态。
  • 在多站点安装中使用 switch_to_blog()restore_current_blog()

此外:

  • 每当发生重定向时,查询监视器都会添加一个包含调用堆栈的 HTTP 标头,因此您可以使用您最喜欢的 HTTP 检查器或浏览器开发人员工具来跟踪触发重定向的内容。
  • 页面上任何 jQuery 发起的 Ajax 请求的响应都将在其标头中包含各种调试信息。 PHP 错误也会输出到浏览器的开发人员控制台。
  • 只要经过身份验证的用户有权查看查询监视器的输出,来自经过身份验证的 WordPress REST API 请求的响应将在其标头中包含性能信息和 PHP 错误的概述。 封装的 REST API 请求将包含更多调试响应的 qm 属性中的信息。

默认情况下,查询监视器的输出仅向单站点安装的管理员显示,对于多站点安装的超级管理员显示。

除此之外,您还可以设置一个身份验证 cookie,允许您在未登录时(或者以非管理员身份登录)查看查询监视器输出。有关详细信息,请参阅“设置”面板。

其它插件

我为开发人员维护了几个其他插件。去看一下:

  • 用户切换提供 WordPress 中用户帐户之间的即时切换。
  • WP Crontrol 可让您查看和控制 WP-Cron 系统中发生的情况

隐私声明

Query Monitor is private by default and always will be. It does not persistently store any of the data that it collects. It does not send data to any third party, nor does it include any third party resources. Query Monitor’s full privacy statement can be found here.

无障碍声明

Query Monitor aims to be fully accessible to all of its users. Query Monitor’s full accessibility statement can be found here.

屏幕截图

  • 管理工具栏菜单
  • 按组件聚合数据库查询
  • 能力检查
  • 数据库查询
  • 勾子和动作
  • HTTP API 请求
  • 通过调用函数聚合数据库查询

常见问题

这个插件可以在 PHP 8 上使用吗?

是的,它经过积极测试,最高可达 PHP 8.2。

谁可以访问查询监视器的输出?

默认情况下,查询监视器的输出仅向单站点安装的管理员显示,对于多站点安装的超级管理员显示。

除此之外,您还可以设置一个身份验证 cookie,该 cookie 允许您在未登录时或以通常无法查看查询监视器输出的用户身份登录时查看查询监视器输出。有关详细信息,请参阅“设置”面板。

查询监视器本身是否会影响页面生成时间或内存使用情况?

简短的回答:是的,但只有一点点。

Long answer: Query Monitor has a small impact on page generation time because it hooks into a few places in WordPress in the same way that other plugins do. The impact is negligible.

On pages that have an especially high number of database queries (in the hundreds), Query Monitor currently uses more memory than I would like it to. This is due to the amount of data that is captured in the stack trace for each query. I have been and will be working to continually reduce this.

我可以阻止查询监视器在长时间运行的请求期间收集数据吗?

是的,如果有任何内容调用 do_action( 'qm/cease' ),那么查询监视器将停止在页面生成的剩余时间内运行。它使自己脱离进一步的数据收集,丢弃迄今为止收集的所有数据,并跳过其信息的输出。

这对于执行大量数据库查询、消耗大量内存或查询监视器不关心的长时间运行操作非常有用,例如:

  • 备份或恢复您的网站
  • Importing or exporting a large amount of data
  • 运行安全扫描

查询监视器有任何附加插件吗?

A list of add-on plugins for Query Monitor can be found here.

此外,查询监视器透明地支持调试栏插件的附加组件。如果您安装了任何调试栏附加组件,请停用调试栏,附加组件将显示在查询监视器的菜单中。

我可以在哪里建议新功能或报告错误?

请使用Query Monitor 的 GitHub 存储库上的问题跟踪器,因为在那里跟踪问题比在wordpress.org 支持论坛。

Altis 上可以使用查询监视器吗?

是的,Altis 开发人员工具构建在查询监视器之上。

WordPress VIP 上可以使用查询监视器吗?

可以,但用户需要被授予 view_query_monitor 功能才能查看查询监视器,即使他们是管理员也是如此。 有关更多详细信息,请参阅 WordPress VIP 文档

我正在使用“wpdb”的多个实例。如何让我的其他实例显示在查询监视器中?

该功能在 3.12 版本中被删除,因为它很少使用,并且大大增加了 Query Monitor 本身的维护负担。如果您需要使用此功能,请随意继续使用版本 3.11。

我可以单击堆栈跟踪以在编辑器中打开文件吗?

是的。您可以在“设置”面板上启用此功能。

How can I report a security bug?

You can report security bugs through the Patchstack Vulnerability Disclosure Program. The Patchstack team helps validate, triage, and handle any security vulnerabilities. Report a security vulnerability here.

你们接受捐款吗?

我正在通过 GitHub 赞助商计划接受赞助. 如果您在一家使用 WordPress 开发的机构工作,请要求您的公司提供赞助以投资其供应链。我维护的工具可能会节省您公司的时间和金钱,并且 GitHub 赞助现在可以在组织级别完成。

此外,如果您喜欢该插件,那么我希望您留下评论。也告诉你所有的朋友吧!

评价

阅读所有443条评价

贡献者及开发者

“Query Monitor – The developer tools panel for WordPress” 是开源软件。 以下人员对此插件做出了贡献。

贡献者

「Query Monitor – The developer tools panel for WordPress」插件已被翻译至 23 种本地化语言。 感谢所有译者为本插件所做的贡献。

将“Query Monitor – The developer tools panel for WordPress”翻译成您的语言。

对开发感兴趣吗?

您可以浏览代码,查看SVN仓库,或通过RSS订阅开发日志

更新日志

3.16.2 (22 April 2024)

  • Fixes another issue with the PHP autoloader in 3.16.0 and 3.16.1 that was crashing some sites

3.16.1 (22 April 2024)

  • Fixes an issue with the PHP autoloader in 3.16.0 that was crashing some sites

3.16.0 (22 April 2024)

  • Adds full support for debugging new features in WordPress 6.5: JavaScript modules and PHP translation files

3.15.0 (10 November 2023)

3.14.1 (21 October 2023)

  • 提高了与 WordPress Playground 的兼容性

3.14.0 (18 October 2023)

  • 更正了显示脚本和样式的 URL 时的端口号处理
  • 改进了在多站点网络中的单个站点上激活和停用查询监视器以及使用 DISALLOW_FILE_MODS 时的 db.php 处理
  • 改进了对调试栏是否存在的检查
  • 将嵌入式插件标识为特定组件而不是“其他”
  • 简化记录查询时使用的一些数据结构
  • 指定 Query Monitor 支持最多三年前的 WordPress 版本

3.13.1 (15 July 2023)

  • Avoids a fatal error if a deprecated warning is triggered early on during the bootstrap process
  • Avoids a PHP warning that can be triggered during certain HTTP API requests when Curl is not in use
  • Skips loading QM during the plugin update process

3.13.0 (9 July 2023)

  • Adds a dedicated panel for “Doing it Wrong” and deprecated functionality usage
  • Allows data in the HTTP API requests panel to be filtered by host name
  • Adds a “Type” column wherever a list of hooks can show both actions and filters
  • Improves various aspects of the “Editor” setting
  • Increases the minimum supported version of PHP to 7.4
  • Many thanks to @crstauf for the majority of the new features in this release

3.12.3 (17 May 2023)

  • Improves theme template part data collection when the Gutenberg plugin is in use with a block theme
  • Skips attempting to resolve a block template if the theme doesn’t support block templates
  • Removes the fallback to $EZSQL_ERROR for database query errors as it’s not possible to determine if the error should be ignored

3.12.2 (27 April 2023)

  • Adds the total count to the table footer of the PHP Errors panel
  • Improves the destination URL for links that point to the site editor
  • Implements some minor visual improvements
  • Removes unreliable information about the transport for HTTP API requests
  • Removes Query Monitor output from the interim login modal

3.12.1 (24 March 2023)

  • Corrects some inter-panel links that point to the Queries panel and sub-panels
  • Switches to sessionStorage for the selected table column filters so they don’t persist across tabs or sessions
  • Removes the “Debug Bar:” prefix on the menus for panels inherited from the Debug Bar plugin

3.12.0 (16 March 2023)

  • Clarifies and improves information in the Template panel when a block theme or full site editing (FSE) is in use
  • Avoids PHP warnings if a third party plugin makes unexpected changes to language file paths
  • Implements some minor performance improvements
  • Removes misleading information about WordPress memory limits
  • Removes support for multiple instances of wpdb (see the FAQ for more information)

3.11.2 (23 February 2023)

  • Implements various accessibility improvements
  • Fixes an issue where not all admin area footer scripts were shown in the Scripts panel
  • Improves output when the SQLite feature in the Performance Labs plugin is in use
  • Removes QM output altogether from the Customizer
  • Ensures wp-content/db.php from another plugin doesn’t get removed when deactivating QM

3.11.1 (3 January 2023)

  • Avoids a fatal error in PHP 8 when posix_getpwuid() or posix_getgrgid() doesn’t return an expected value.

3.11.0 (30 December 2022)

  • Adds a new “Multisite” panel that shows usage of switch_to_blog() and restore_current_blog() on Multisite installations
  • Improves the output shown for blocks and template parts when block themes or full site editing is in use
  • Introduces new QM_Data and QM_Component classes to make the data collection more structured and reliable
  • Increases the minimum supported version of PHP to 7.2
  • Improves the performance of SVG icons
  • Removes the ability to completely hide silenced PHP errors
  • Avoids some deprecated notices in PHP 8.2
  • Improves the performance of the PHP class autoloader

3.10.1 (9 September 2022)

  • Prevents logging duplicate entries for multiple calls to load the same translation file
  • Brings the dispatcher priority back down to 9 for maximum compatibility with other plugins that use a shutdown handler

3.10.0 (8 September 2022)

  • Adds information about the current language on the Languages panel
  • Reduces the chance that Query Monitor blames itself for PHP errors that don’t have a stack trace
  • Replaces the use of Dashicons with inline SVGs and removes the dashicons dependency
  • Switches to class autoloading via Composer for reduced memory usage
  • Changes the priority of the shutdown dispatcher from 0 to PHP_INT_MAX to ensure as much data as possible is collected
  • Improves the styling of Debug Bar add-ons
  • Fixes some erroneous localisation of float values in REST API output
  • Bumps the minimum supported PHP version to 5.6
  • Improves various other bits and bobs

Earlier versions

For the changelog of earlier versions, please refer to the releases page on GitHub.