query-monitor icon indicating copy to clipboard operation
query-monitor copied to clipboard

null on trim

Open lazardanlucian opened this issue 1 year ago • 5 comments

We have some cases where our pages in wp-admin don't work.

Fatal error: Uncaught Error: trim(): Argument #1 ($string) must be of type string, null given in /var/www/wp-content/mu-plugins/query-monitor/collectors/raw_request.php on line 73

lazardanlucian avatar Oct 25 '23 08:10 lazardanlucian

Thanks for the PR. It sounds like your server is outputting an HTTP header in an unexpected format. Can you provide a list of the headers in the response so we can see what's up?

johnbillion avatar Oct 25 '23 09:10 johnbillion

Hello, I found the issue. There was a header set without a value, from a php snippets plugin.

This still could be useful here, since a header without a value will not break anything, why have it break qm

lazardanlucian avatar Oct 25 '23 09:10 lazardanlucian

array (size=3) 0 => string 'X-Powered-By: PHP/8.0.27' (length=24) 1 => string 'Sample-Header-No-Value' (length=22) 2 => string 'Test: Value' (length=11)

this will break QM and wp-admin pages where Sample header exists

lazardanlucian avatar Oct 25 '23 09:10 lazardanlucian

@johnbillion Although the RFC mandate a header value, I'm not sure if the application should break if there is a header without a value.

So our problem is fixed by fixing the header, so it's up to you how you want to treat this 🤖

lazardanlucian avatar Oct 25 '23 09:10 lazardanlucian

Thanks, I'll make some adjustments to the header handling to handle this.

johnbillion avatar Oct 25 '23 12:10 johnbillion