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

FILTER_SANITIZE_STRING is deprecated in php 8.1 #234

Closed
edwinbradford opened this issue Jul 6, 2023 · 2 comments · Fixed by #244
Closed

FILTER_SANITIZE_STRING is deprecated in php 8.1 #234

edwinbradford opened this issue Jul 6, 2023 · 2 comments · Fixed by #244

Comments

@edwinbradford
Copy link

Describe the bug

I can't find a report of this issue so I'm submitting it.

The below error occurs when running Multisite Language Switcher in PHP version 8.1. This StackOverflow answer states FILTER_SANITIZE_STRING is deprecated in php 8.1 and there are multiple suggestions on how to update it.

I have changed...

$action = filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRING ); to
$action = filter_input( INPUT_POST, 'action', FILTER_SANITIZE_FULL_SPECIAL_CHARS );

...in MslsPlugin.php which appears to work fine but I don't understand exactly what it does.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Settings > General > Multisite Language Switcher.
  2. Click on 'Save Changes' (you do not need to make a change).
  3. See the following error:

Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /var/www/html/wp-content/plugins/multisite-language-switcher/includes/MslsPlugin.php on line 77 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/multisite-language-switcher/includes/MslsPlugin.php:77) in /var/www/html/wp-admin/includes/misc.php on line 1431 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/multisite-language-switcher/includes/MslsPlugin.php:77) in /var/www/html/wp-includes/functions.php on line 6896 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/multisite-language-switcher/includes/MslsPlugin.php:77) in /var/www/html/wp-includes/pluggable.php on line 1427 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/multisite-language-switcher/includes/MslsPlugin.php:77) in /var/www/html/wp-includes/pluggable.php on line 1430

Expected behaviour
There should be no error in PHP versions 8.1 or above.

Environment:

  • OS: WSL2 Ubuntu running Docker
  • Browser: Chrome in Windows
  • PHP Version 8.1
  • Plugin Version 2.5.8
@lloc
Copy link
Owner

lloc commented Aug 3, 2023

This commit closes the issue. Thanks!

@lloc lloc closed this as completed Aug 3, 2023
@edwinbradford
Copy link
Author

Not sure if its relevant but I found three instances of FILTER_SANITIZE_STRING in the repo. There is one in MslsMetaBox.php and one in WithRequestPostAttributes.php. I've changed them all to FILTER_SANITIZE_FULL_SPECIAL_CHARS and there don't appear to be any issues but I was never able to figure out how to build the repo locally and submit a pull request so I just made the changes directly in the built plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants