Skip to content

Fix undefined array key "scheme" and "host" in FastCGI purger#499

Open
boutier-design wants to merge 1 commit intortCamp:masterfrom
boutier-design:master
Open

Fix undefined array key "scheme" and "host" in FastCGI purger#499
boutier-design wants to merge 1 commit intortCamp:masterfrom
boutier-design:master

Conversation

@boutier-design
Copy link
Copy Markdown

Problem

When saving a page in Breakdance Builder, the admin-ajax request
triggers a post save action which calls the FastCGI purger. In
some cases, parse_url() does not return a "scheme" or "host" key
(e.g. when the URL passed is relative or malformed), causing a
fatal 500 error:

Undefined array key "scheme"
Undefined array key "host"

Fix

Added null coalescing fallbacks on 3 locations in class-fastcgi-purger.php:

  • scheme defaults to 'https'
  • host defaults to $_SERVER['HTTP_HOST']
  • path defaults to '/'

Tested on

  • WordPress 6.x
  • Breakdance Builder
  • nginx-helper 2.3.5

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant