-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle empty and malformed $_SERVER request variables #122
Handle empty and malformed $_SERVER request variables #122
Conversation
When WordPress is loaded locally, i.e. without a HTTP request, the expected `$_SERVER['REQUEST_METHOD']` is not set, resulting in `PHP Notice: Undefined index: REQUEST_METHOD in /path/to/wp-content/plugins/satispress/src/ServiceProvider.php on line 156` being logged. The commit checks if WordPress is `DOING_CRON` and if so, returns a instantiated but unconfigured `Request` (`WP_REST_Request`) object.
Thanks for the PR, @BrianHenryIE! Rather than check
Does that work for you? |
As per discussion on PR
Fix for: PHP Fatal error: Uncaught TypeError: ltrim() expects parameter 1 to be a string, bool given `get_request_path()` is called in two places: `authentication.php:83` and `authentication.php:164`, both then preform a string function to determine true/false, so returning an empty string shoud work fine here.
Yeah, that should work too. I wrote it as a cron check because I was being too lazy too consider any other means of invocation. It probably affects I had another two related logs this morning. |
Can you clarify how you're loading WordPress that's causing those notices to be triggered? I believe WordPress should populate |
I looked at my transfer logs and it seems that was triggered by: So
They're causing The multiple sequential but that doesn't seem like the right way to address it. |
Was that request also the one that causes that issue that led to e6a7a67? Or is that unrelated? It looks like WordPress does a lot of processing to determine the request path. I'd rather not parse the URI more than absolutely necessary, especially since this is for an invalid request. Since that method is really only used for determining if it's a SatisPress request, we could either |
So, two unrelated requests. First is from starting WordPress via cron or command line. Second is via HTTP with a malformed REQUEST_URI. Sorry for mixing up the PR. I think the
That should accommodate other malformed URLs that might come up, and the behaviour is still correct. |
Thanks for the explanation. I just wanted to make sure I understood when these issues were occurring. If you want to push up that fix, I'll get this merged. |
Discovered when: `$_SERVER['REQUEST_URI'] = ///?author=1` (possible [phishing attempt](https://htaccessbook.com/block-user-id-phishing/))
Thanks @BrianHenryIE! I squashed a couple of commits and merged this manually, so it didn't close automatically, but they have been committed. I appreciate you reporting and discussing this. 🍻 |
When WordPress is loaded locally, i.e. without a HTTP request, the expected
$_SERVER['REQUEST_METHOD']
is not set, resulting inPHP Notice: Undefined index: REQUEST_METHOD in /path/to/wp-content/plugins/satispress/src/ServiceProvider.php on line 156
being logged.The commit checks if WordPress is
DOING_CRON
and if so, returns a instantiated but unconfiguredRequest
(WP_REST_Request
) object.