Remove deprecated FILTER_SANITIZE_STRING usage. #2768
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed in this Pull Request:
Remove deprecated FILTER_SANITIZE_STRING usage.
Closes #2588.
str_truncate
,str_exists
,str_truncate
and other related string helper methods in theWooCommerce\Facebook\Framework\Helper
class had a fallback for cases where thembstring
PHP extension was not available. This fallbackstr_to_ascii
method would throw a deprecate warning notice because of its use of the FILTER_SANITIZE_STRING constant.I have considered removing the
self::multibyte_loaded()
check and falling back on the WP core polyfill. But some mb functions do not have polyfills in the core likemb_strpos
. This will require including and loading something like https://github.com/symfony/polyfill-mbstring.We can look at this when we work on the cleanup task: #2705.
Here, I re-implement str_ascii without filter_var. This keeps printable ASCII chars, stripping out everything from 0-31 and 127-255,.
phpcs
checks? Please removephpcs:ignore
comments in changed files and fix any issues, or delete if not practical.Screenshots:
Detailed test instructions:
To reproduce:
facebook-for-woocommerce/includes/Framework/Helper.php
Line 155 in f8b103d
Check out this branch.
You can try to sync a product by editing it; for example, no warning notice should be thrown.
Changelog entry