Skip to content
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

Undefined array key in class-fremius.php:4232 #731

Open
TobiasBg opened this issue Aug 6, 2024 · 3 comments
Open

Undefined array key in class-fremius.php:4232 #731

TobiasBg opened this issue Aug 6, 2024 · 3 comments

Comments

@TobiasBg
Copy link

TobiasBg commented Aug 6, 2024

Reported by @MacGyer in TablePress/TablePress#199:

When CLI scripts run, an error is thrown:

PHP Warning: Undefined array key "HTTP_HOST" in /path/to/tablepress/libraries/freemius/includes/class-freemius.php on line 4232

https://github.com/Freemius/wordpress-sdk/blob/master/includes/class-freemius.php#L4232

  • WP: 6.6.x
  • TablePress: 2.4
  • OS: Linux Mint 20.3
  • PHP: 8.1.x
@todeveni
Copy link

Error has moved, but is still present.

Warning: Undefined array key "HTTP_HOST" in tablepress/libraries/freemius/includes/class-freemius.php on line 3910

@Mr2P
Copy link

Mr2P commented Jan 6, 2025

My customers have also reported this issue. They encountered the error while running a cron job. The PHP CLI does not have access to $_SERVER['HTTP_HOST'].

@Mathias-Witt
Copy link

Mathias-Witt commented Jan 7, 2025

We solved this problem, by adding the --url flag to our wp cli command.
Doc: https://make.wordpress.org/cli/handbook/references/config/

Example:
wp cron event run --due-now --url=https://www.your-http-host.com

the --url parameter calls the WP_CLI::set_url() function and sets $_SERVER['HTTP-HOST']
https://github.com/wp-cli/wp-cli/blob/0187f2b4ce7e83f31bf4beecd5ad4f11ddf8b57b/php/class-wp-cli.php#L121
https://github.com/wp-cli/wp-cli/blob/0187f2b4ce7e83f31bf4beecd5ad4f11ddf8b57b/php/class-wp-cli.php#L127

Maybe it helps

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

No branches or pull requests

4 participants