Skip to content

Infinite loop in Query Monitor when handling translations causing XDebug stack overflow #972

@mralaminahamed

Description

@mralaminahamed

Description

Query Monitor is triggering an infinite recursion loop during translation loading, causing XDebug to abort script execution after reaching the maximum stack depth of 512 frames.

Issue Details

  • Error: PHP Fatal error: Uncaught Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '512' frames
  • WordPress Version: 6.7.0 (based on error message)
  • Environment: Local development with XDebug enabled
  • Reproduction Path: Plugin attempts to load translations for the 'query-monitor' text domain

Steps to Reproduce

  1. Use the latest WordPress (6.7.0+)
  2. Ensure XDebug is installed and enabled on your development environment
  3. Deactivate the Query Monitor plugin
  4. Reactivate the Query Monitor plugin
  5. The error should occur immediately after reactivation

Stack Trace Analysis

The error occurs in a circular dependency between WordPress translation functions and Query Monitor capability checks. The stack trace shows a repeating pattern where:

  • WordPress tries to load translations for Query Monitor
  • This triggers capability checks via Query Monitor's hooks
  • These capability checks attempt to get more translations
  • This leads to an infinite recursion

Possible Causes

  1. Query monitor removed the 'view_query_monitor' capability on deactivation https://github.com/johnbillion/query-monitor/blob/develop/classes/Activation.php#L56-L62
  2. Query Monitor hooks into capability checks that run during translation loading
  3. The QM_Collector_Doing_It_Wrong->maybe_prevent_doing_it_wrong_error() method seems to be in the recursion path https://github.com/johnbillion/query-monitor/blob/develop/collectors/doing_it_wrong.php#L96-L102
  4. Translation loading for Query Monitor's text domain is occurring before the plugin is fully initialized

Impact

This issue causes sites with XDebug enabled to crash during plugin activation, making debugging difficult and potentially affecting development environments.

Screenshots

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions