• Resolved paolurso

    (@paolurso)


    Hi,

    BerqWP 4.1.12 can trigger a reproducible fatal error because its advanced-cache drop-in calls a WordPress function before WordPress has loaded the file that defines it.

    Environment tested:

    • BerqWP 4.1.12
    • WordPress 7.0.4
    • PHP 8.3
    • Reverse-proxy/origin setup

    Cause:
    wp-settings.php loads wp-content/advanced-cache.php very early. The BerqWP drop-in includes inc/common-functions.php and calls bwp_serve_advanced_cache(). In common-functions.php, the non-HTTPS branch calls:

    wp_parse_url(get_option(‘home’), PHP_URL_SCHEME)

    At that point wp_parse_url() is not available yet, because it is defined in wp-includes/http.php, which WordPress loads later in the bootstrap sequence.

    Generic reproduction:

    curl -i -H ‘Host: example.test’ http://127.0.0.1:8081/robots.txt

    Observed result:

    PHP Fatal error: Uncaught Error: Call to undefined function wp_parse_url()
    Stack: common-functions.php -> bwp_serve_advanced_cache() -> advanced-cache.php -> wp-settings.php

    The issue may be hidden on public HTTPS traffic when the proxy supplies an HTTPS signal, but it remains reproducible for direct origin HTTP requests, health checks, audits, or proxy configurations where HTTPS is not exposed through $_SERVER[‘HTTPS’].

    The relevant advanced-cache.php and common-functions.php code is unchanged between BerqWP 4.1.11 and 4.1.12, so the issue is still present in 4.1.12.

    Suggested fix:
    Because this code executes before the full WordPress bootstrap, it should avoid calling functions that are not guaranteed to exist. For the absolute home URL, a minimal fix would be:

    parse_url((string) get_option(‘home’), PHP_URL_SCHEME)

    Alternatively, use a guarded fallback:

    function_exists(‘wp_parse_url’)
    ? wp_parse_url((string) get_option(‘home’), PHP_URL_SCHEME)
    : parse_url((string) get_option(‘home’), PHP_URL_SCHEME)

    A fail-open guard around the early cache bootstrap would also prevent an optional cache layer from taking down the whole WordPress request.

    I would avoid loading wp-includes/http.php manually or defining a wp_parse_url() polyfill in the drop-in, because WordPress later loads that file itself and this could cause duplicate declarations or bootstrap incompatibilities.

    Could you please confirm and include an upstream fix in the next release?

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Hamza Mairaj

    (@thevisionofhamza)

    Hey there,

    I appreciate the detailed error report. We’ll work on that. The fix will definitely be included in the next plugin update. I’ll keep you posted here.

    Cheers,
    Hamza

    Plugin Author Hamza Mairaj

    (@thevisionofhamza)

    Hey there,

    We’ve rolled out a plugin update (v4.1.13) addressing the error. Thanks for reporting the bug.

    I’m marking this ticket as resolved. If you have any further questions, please feel free to reply.

    Cheers,
    Hamza

    Thread Starter paolurso

    (@paolurso)

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.