From fd647b3d1c3697fcd218aca9c6acbd1c08fef5fb Mon Sep 17 00:00:00 2001 From: Jordy Boutier Date: Thu, 5 Mar 2026 11:02:51 +0100 Subject: [PATCH] Fix undefined array key "scheme" and "host" in FastCGI purger parse_url() does not always return a "scheme" or "host" key, for example when called during a Breakdance Builder save via admin-ajax. This causes a fatal 500 error. Added null coalescing fallbacks for "scheme" (defaults to "https") and "host" (defaults to $_SERVER['HTTP_HOST']) on lines 51, 146 and 277. --- admin/class-fastcgi-purger.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/class-fastcgi-purger.php b/admin/class-fastcgi-purger.php index a6ee9e9..b995c6b 100644 --- a/admin/class-fastcgi-purger.php +++ b/admin/class-fastcgi-purger.php @@ -48,7 +48,7 @@ public function purge_url( $url, $feed = true ) { switch ( $nginx_helper_admin->options['purge_method'] ) { case 'unlink_files': - $_url_purge_base = $parse['scheme'] . '://' . $parse['host'] . $parse['path']; + $_url_purge_base = ( $parse['scheme'] ?? 'https' ) . '://' . ( $parse['host'] ?? $_SERVER['HTTP_HOST'] ) . ( $parse['path'] ?? '/' ); $_url_purge = $_url_purge_base; if ( ! empty( $parse['query'] ) ) { @@ -143,7 +143,7 @@ public function custom_purge_urls() { switch ( $nginx_helper_admin->options['purge_method'] ) { case 'unlink_files': - $_url_purge_base = $parse['scheme'] . '://' . $parse['host']; + $_url_purge_base = ( $parse['scheme'] ?? 'https' ) . '://' . ( $parse['host'] ?? $_SERVER['HTTP_HOST'] ); if ( is_array( $purge_urls ) && ! empty( $purge_urls ) ) { @@ -274,7 +274,7 @@ private function purge_base_url() { // Prevent users from inserting a trailing '/' that could break the url purging. $path = trim( $path, '/' ); - $purge_url_base = $parse['scheme'] . '://' . $parse['host'] . '/' . $path; + $purge_url_base = ( $parse['scheme'] ?? 'https' ) . '://' . ( $parse['host'] ?? $_SERVER['HTTP_HOST'] ) . '/' . $path; /** * Filter to change purge URL base for FastCGI cache.