johnbillion / query-monitor

The developer tools panel for WordPress
https://querymonitor.com
GNU General Public License v2.0
1.6k stars 211 forks source link

null on trim #824

Open lazardanlucian opened 1 year ago

lazardanlucian commented 1 year ago

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

johnbillion commented 1 year ago

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?

lazardanlucian commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@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 🤖

johnbillion commented 1 year ago

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