Undefined array key “SERVER_NAME”
-
There are a few threads on this but none of them were actually mine, it is probably best practice to not hijack others.
error_log is filled with this error:
[28-Nov-2025 14:44:06 UTC] PHP Warning: Undefined array key "SERVER_NAME" in /home/username/public_html/wp-content/plugins/mailchimp-for-woocommerce/includes/class-mailchimp-woocommerce-enhanced-logger.php on line 258I might have identified the problem for you. The plugin is relying on SERVER_NAME, but if you use cronjobs or WP-CLI, that isn’t populated either at all, or the same.
For our websites, we have WP Cron and rely on a cronjob. I see another unresolved thread where someone is using WP-CLI.Google’s AI (I know I know) suggestion:
Use $current_site->domain: For WordPress-specific operations, it is more reliable to use the $current_site global object, which stores the domain variable ($current_site->domain), instead of relying on $_SERVER[‘SERVER_NAME’]. This ensures that the correct domain information is used regardless of whether the command is executed via the web or WP-CLI.
You must be logged in to reply to this topic.