You've already forked wp-prometheus
fix: Resolve memory exhaustion with Twig-based plugins (v0.4.1)
All checks were successful
Create Release Package / build-release (push) Successful in 57s
All checks were successful
Create Release Package / build-release (push) Successful in 57s
- Add early metrics endpoint handler to intercept /metrics before full WP init - Remove content filters during metrics collection to prevent recursion - Skip extensibility hooks in early metrics mode - Change template_redirect to parse_request for earlier interception Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,7 +45,9 @@ class MetricsEndpoint {
|
||||
*/
|
||||
private function init_hooks(): void {
|
||||
add_action( 'init', array( $this, 'register_endpoint' ) );
|
||||
add_action( 'template_redirect', array( $this, 'handle_request' ) );
|
||||
// Use parse_request instead of template_redirect to handle the request early,
|
||||
// before themes and other plugins (like Twig-based ones) can interfere.
|
||||
add_action( 'parse_request', array( $this, 'handle_request' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,10 +68,13 @@ class MetricsEndpoint {
|
||||
/**
|
||||
* Handle the metrics endpoint request.
|
||||
*
|
||||
* Called during parse_request to intercept before themes/plugins load.
|
||||
*
|
||||
* @param \WP $wp WordPress environment instance.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_request(): void {
|
||||
if ( ! get_query_var( 'wp_prometheus_metrics' ) ) {
|
||||
public function handle_request( \WP $wp ): void {
|
||||
if ( empty( $wp->query_vars['wp_prometheus_metrics'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user