wp-cli/server-command

$_SERVER['SERVER_ADDR'] is missing

szepeviktor opened this issue · 5 comments

It seems php -S does not set it.
May I send a PR that sets it to 127.0.0.1 in the router?

Alternatively add a --command-line-option to set it...

@szepeviktor I'm not a fan of hardcoding an IP address like that.

How about something like this:

$_SERVER['SERVER_ADDR'] = gethostbyname( $_SERVER['SERVER_NAME'] );

It would set the SERVER_ADDR to the IP address the current hist name resolves to. For localhost on my system, this results in it being set to 127.0.0.1, for example.

Not sure what edge cases we might encounter with this, though...

Not sure what edge cases we might encounter with this, though...

My WAF checks for it: https://github.com/szepeviktor/wordpress-fail2ban/blob/master/block-bad-requests/wp-fail2ban-bad-request-instant.inc.php#L150

I send the PR...

Thank you.

Not sure what edge cases we might encounter with this, though...

I was referring to the potential edge cases that might arise by using gethostbyname( $_SERVER['SERVER_NAME'] ).

I merged the PR now, I don't know how else to find out, really...