Skip to content
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

Stop using filter_input with $_SERVER variables #254

Closed
shadyvb opened this issue Feb 19, 2014 · 6 comments · Fixed by #263
Closed

Stop using filter_input with $_SERVER variables #254

shadyvb opened this issue Feb 19, 2014 · 6 comments · Fixed by #263
Labels

Comments

@shadyvb
Copy link
Contributor

shadyvb commented Feb 19, 2014

Because of a PHP confirmed bug, filter_input( INPUT_SERVER, 'anything' ) would return null on some implementations of FCGI/PHP 5.4 ( and probably older versions as well ).
https://bugs.php.net/bug.php?id=49184

Use workaround mentioned in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=730094:

if (filter_has_var(INPUT_SERVER, "SERVER_NAME")) {
        $servername = filter_input(INPUT_SERVER, "SERVER_NAME",
FILTER_UNSAFE_RAW, FILTER_NULL_ON_FAILURE);
    } else {
        if (isset($_SERVER["SERVER_NAME"]))
            $servername = filter_var($_SERVER["SERVER_NAME"],
FILTER_UNSAFE_RAW, FILTER_NULL_ON_FAILURE);
        else
            $servername = null;
    }

Reported at https://wordpress.org/support/topic/ip-addresses-not-showing-being-added-to-db-in-version-119?replies=9

@frankiejarrett
Copy link
Contributor

@shadyvb How obscure! Good on ya.

@westonruter
Copy link
Contributor

Interesting. Yeah, and Nacin said that the filter_* functions aren't allowed in core because of un-guaranteed availability. I've removed them from Widget Customizer.

@shadyvb
Copy link
Contributor Author

shadyvb commented Feb 19, 2014

That's just sad :(

@jonathanbardo
Copy link
Contributor

Good to know. It's a shame they are not super reliable. Should we try to avoid them in the future @westonruter?

@westonruter
Copy link
Contributor

@jonathanbardo yeah, unfortunately I think we can't rely on them if they aren't reliable for core.

@frankiejarrett
Copy link
Contributor

Sorry I must have closed this by accident! Fail

@shadyvb shadyvb closed this as completed Feb 20, 2014
jonathanbossenger added a commit to CastosHQ/Seriously-Simple-Podcasting that referenced this issue May 19, 2017
elindydotcom added a commit to Awesome-Support/Awesome-Support that referenced this issue Nov 2, 2017
…d a bug where the filter_input and INPUT_SERVER combination would sometimes erroneously return null. See xwp/stream#254 for more information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants