Site logo

[Support request] PHP 8 warning for FILTER_SANITIZE_STRING

Home Forums Support [Support request] PHP 8 warning for FILTER_SANITIZE_STRING

Home Forums Support PHP 8 warning for FILTER_SANITIZE_STRING

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2431875
    roadlink

    Hi there,

    I have like thousands of lines in error.log file about this function.

    PHP Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /wordpress/mu-plugins/atomic-platform.php on line 559

    I have checked with hosting and they told me that it is related with my theme.
    I have searched for FILTER_SANITIZE_STRING in theme files and find below results.

    generatepress\inc\meta-box.php (4 hits)
    	Line 231: 	$sidebar_layout_value = filter_input( INPUT_POST, $sidebar_layout_key, FILTER_SANITIZE_STRING );
    	Line 240: 	$footer_widget_value = filter_input( INPUT_POST, $footer_widget_key, FILTER_SANITIZE_STRING );
    	Line 250: 	$page_builder_container_value = filter_input( INPUT_POST, $page_builder_container_key, FILTER_SANITIZE_STRING );
    	Line 261: 	$disable_content_title_value = filter_input( INPUT_POST, $disable_content_title_key, FILTER_SANITIZE_STRING );

    here are some search results about this.
    https://stackoverflow.com/questions/69207368/constant-filter-sanitize-string-is-deprecated
    https://laxmariappan.com/filter_sanitize_string-is-deprecated-what-to-use-instead/

    #2431888
    roadlink

    Another plugin solved it like below according to their comment.

    /*
         * Replacer for FILTER_SANITIZE_STRING deprecated with PHP 8.1
         */
        public static function filter_string_polyfill(string $string): string {
            
            $str = preg_replace('/\x00|<[^>]*>?/', '', $string);
            return str_replace(["'", '"'], [''', '"'], $str);
            
        }
        // end of filter_string_polyfill()
    #2431926
    Leo
    Staff
    Customer Support

    Hi there,

    Can you confirm that you are using the latest versions of the theme and premium plugin?
    https://docs.generatepress.com/article/generatepress-and-gp-premium/

    The initial error doesn’t look like it’s related to the theme.

    Can you disable all non-GP plugins to test?

    Let me know 🙂

    #2432304
    roadlink

    Hi Leo,

    Yes both GP and GPP are latest versions.

    FILTER_SANITIZE_STRING is deprecated and this file still has it. generatepress\inc\meta-box.php

    I don’t see any point to disable others plugins and check again.

    #2432709
    David
    Staff
    Customer Support

    Hi there,

    thanks for reporting that we will take a look at getting that replaced.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.