• Resolved WEBHAUS

    (@webhaus)


    Hello, found one more bug, which happens when $_SERVER[‘SERVER_NAME’] variable is empty (this could happen when some server side cron tasks are being executed).

    PHP Warning: Undefined array key "SERVER_NAME" in /home/xxxxx/public_html/wp-content/plugins/woo-save-abandoned-carts/admin/class-cartbounty-admin.php on line 1923

    I’d suggest that you replace this line:

    $sender = 'WordPress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));

    with the following:

    if(!empty($_SERVER['SERVER_NAME'])) {
    			$server_name = $_SERVER['SERVER_NAME'];
    		} else {
    			$site_url_parsed = parse_url(site_url());
    			$server_name = !empty($site_url_parsed) && !empty($site_url_parsed['host']) ? $site_url_parsed['host'] : 'system';
    		}
    		$sender = 'WordPress@' . preg_replace('#^www\.#', '', strtolower($server_name));

    This uses a hostname from site URL as a primary fallback (secondary fallback – just a string “system”) in cases when SERVER_NAME is empty.

    • This topic was modified 4 years, 3 months ago by WEBHAUS.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Nauriskolats

    (@nauriskolats)

    Hi, @webhaus

    Thanks for bringing this up to our attention!
    We will take care of this issue in the next release.

    Best wishes,
    Nauris

    Plugin Contributor Nauriskolats

    (@nauriskolats)

    Hi @webhaus, sorry for making you wait that long, but the new release takes care of the issue you reported.

    Thank you very much for helping identify it!

    Best wishes
    Nauris

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP warnings when SERVER_NAME is empty’ is closed to new replies.