Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter tlunt

    (@tlunt)

    No problem, thanks for looking into this

    The site runs Apache 2.4 (Debian) with PHP 8.3, using the official wordpress:latest Docker image. It sits behind a Traefik reverse proxy and Cloudflare.

    Also here are the runtime logs from the container, this was throwing anytime :

    [Fri Oct 02 14:03:58.583631 2026] [php:error] [pid 223433:tid 223433] [client ] PHP Fatal error: Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, array given in /var/www/html/wp-content/plugins/wp-optimize/webp/class-wpo-webp-self-test.php:43
    Stack trace:
    #0 /var/www/html/wp-content/plugins/wp-optimize/webp/class-wpo-webp-self-test.php(43): preg_match('/accept/i', Array)
    #1 /var/www/html/wp-content/plugins/wp-optimize/webp/class-wpo-webp-self-test.php(71): WPO_WebP_Self_Test->has_vary(Array)
    #2 /var/www/html/wp-content/plugins/wp-optimize/webp/class-wp-optimize-webp.php(454): WPO_WebP_Self_Test->is_webp_served()
    #3 /var/www/html/wp-content/plugins/wp-optimize/webp/class-wp-optimize-webp.php(269): WP_Optimize_WebP->run_webp_serving_self_test()
    #4 /var/www/html/wp-content/plugins/wp-optimize/webp/class-wp-optimize-webp.php(227): WP_Optimize_WebP->is_webp_redirection_possible()
    #5 /var/www/html/wp-content/plugins/wp-optimize/includes/class-wpo-page-optimizer.php(286): WP_Optimize_WebP->maybe_decide_webp_serve_method('...') #6 /var/www/html/wp-content/plugins/wp-optimize/includes/class-wpo-page-optimizer.php(51): WPO_Page_Optimizer->maybe_alter_html_for_webp('...')
    #7 [internal function]: WPO_Page_Optimizer->optimize('...', 9)
    #8 /var/www/html/wp-includes/functions.php(5581): ob_end_flush()
    #9 /var/www/html/wp-includes/class-wp-hook.php(353): wp_ob_end_flush_all('') #10 /var/www/html/wp-includes/class-wp-hook.php(377): WP_Hook->apply_filters('', Array)
    #11 /var/www/html/wp-includes/plugin.php(523): WP_Hook->do_action(Array)
    #12 /var/www/html/wp-includes/load.php(1308): do_action('shutdown')
    #13 [internal function]: shutdown_action_hook()
    #14 {main} thrown in /var/www/html/wp-content/plugins/wp-optimize/webp/class-wpo-webp-self-test.php on line 43

    What triggers it is the Vary header coming back as two separate header lines, not one combined line. This is the response to the self-test image request (/wp-content/uploads/wpo/images/wpo_logo_small.png with Accept: image/webp):

    HTTP/2 200
    content-type: image/webp
    vary: Accept-Encoding
    vary: Accept

    When a header is repeated, wp_remote_retrieve_headers() returns its value as an array. has_vary() then passes that array to preg_match(), which throws the TypeError on PHP 8.

Viewing 1 replies (of 1 total)