• Moderator bcworkz

    (@bcworkz)


    I now get this notice when calling get_footer() while outputting a Twenty Twenty-one themed page requested through admin-post.php:
    Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /var/www/wptest/wp-includes/class-wp-scripts.php on line 705
    Same for line 710.

    The issue occurs when this theme tries to load script ‘twenty-twenty-one-ie11-polyfills’. It does not occur on normal WP post and page requests, it’s only when get_footer() is called from an admin-post.php request, which my plugin does to output a page styled like the currently active theme would do.

    Other themes I’ve tested don’t have any trouble loading their footer scripts, this is the only one I’ve had trouble with.

    Twenty Twenty-one v1.8, WP v6.2, PHP v8.2

    To reproduce, add this code to any plugin main file or theme’s functions.php (with WP_DEBUG defined as true):

    add_action('admin_post_test-page', 'bcw_dotest');
    add_action('admin_post_nopriv_test-page', 'bcw_dotest');
    function bcw_dotest() {
    	set_current_screen('test-page');
    	get_header(); ?>
              Hello world!.
    	<?php get_footer();
    }

    Make a request similar to the one below.

    This surely has to do with upgrading to PHP v8.x. I’ve managed to work around the issue with this:

    // change any source passed as null to empty string
    add_filter('script_loader_src', 'bcw_script_src', 10, 2 );
    function bcw_script_src( $src, $handle ) {
    	return is_null($src) ? '' : $src;
    }

    This surely would affect very few people, it might just be me. But since I noticed it and found a workaround, I thought I’d report it. Since I found a workaround, there’s no need to make a correction on my behalf, but someone might want to do so just on principle.

    Thanks for reading about my little issue ??

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Hi @bcworkz – thanks for the report. While you’re right in that this is probably a pretty edge case (most people wouldn’t be calling get_footer() on the admin side) I did mention it in this Core ticket that discusses the same error in other contexts.

Viewing 1 replies (of 1 total)
  • The topic ‘Deprecated notice when outputting footer thru admin-post.php’ is closed to new replies.