str_truncate, str_exists, str_truncate and other related string helper methods in the WooCommerce\Facebook\Framework\Helper class had a fallback for cases where the mbstring PHP extension was not available. This fallback str_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 like mb_strpos. This will require including and loading something like https://github.com/symfony/polyfill-mbstring.
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: https://github.com/woocommerce/facebook-for-woocommerce/issues/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:
Check out this branch.
You can try to sync a product by editing it; for example, no warning notice should be thrown.
Changelog entry