Skip to content

WordPress Plugins and Themes with Known Issues Doc Update #9424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dficker opened this issue Feb 7, 2025 · 2 comments · May be fixed by #9478
Open

WordPress Plugins and Themes with Known Issues Doc Update #9424

dficker opened this issue Feb 7, 2025 · 2 comments · May be fixed by #9478
Assignees
Labels
Type: Quick Fix Issues that should be resolvable in a small PR

Comments

@dficker
Copy link
Contributor

dficker commented Feb 7, 2025

Re: WordPress Plugins and Themes with Known Issues and SERVER_NAME and SERVER_PORT on Pantheon

Priority: Medium

Issue Description:

A few places have this line of code in our Docs as a workaround:

$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];

This solves some sort of issue for some plugins, but it also causes PHP Warnings when WP-CLI is executed. The "php-error.log" file will have errors like this one:

PHP Warning: Undefined array key "HTTP_HOST" in phar:///opt/pantheon/wpcli/wp-cli-2.11.0.phar/vendor/wp-cli/config-command/src/Config_Command.php(556) : eval()'d code on line 90

In a few recent cases, I think these PHP Warnings being present caused the Multisite Search-replace function of the platform to not work and error out. And I've seen a few other sites doing this and getting PHP Warnings as well.

Suggested Resolution

I think all these suggestions should be updated to this:

if (php_sapi_name() != 'cli') {
  $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
}
@rachelwhitton rachelwhitton self-assigned this Feb 11, 2025
@rachelwhitton rachelwhitton added the Type: Quick Fix Issues that should be resolvable in a small PR label Mar 12, 2025
@rachelwhitton rachelwhitton linked a pull request Mar 12, 2025 that will close this issue
@jazzsequence
Copy link
Contributor

This issue is solved if you use the PANTHEON_HOSTNAME constant that was added to wp-config-pantheon.php and config/application.php (for Bedrock Composer-based sites).

See: https://github.com/pantheon-systems/WordPress/blob/default/wp-config-pantheon.php#L99-L104

The constant checks if HTTP_HOST is defined and defines a default if not. We should be recommending people to use PANTHEON_HOSTNAME to solve these issues, rather than needing to check for WP-CLI specifically.

@jazzsequence
Copy link
Contributor

Updated #9478 to use PANTHEON_HOSTNAME instead of recommending setting HTTP_HOST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Quick Fix Issues that should be resolvable in a small PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants