• Resolved WEBHAUS

    (@webhaus)


    Hello,

    I’ve noticed that on the latest version of your plugin, sometimes a PHP Warning is getting triggered about undefined variable / array key $_SERVER[‘SERVER_PORT’]. It could happen when the server-side PHP cron job is running with WordPress loaded.

    PHP Warning: Undefined array key "SERVER_PORT" in /home/xxxxxx/public_html/wp-content/plugins/multiparcels-shipping-for-woocommerce/includes/class-mp-api-client.php on line 52

    As the error message says, the error is on line 52 of this file: /includes/class-mp-api-client.php.

    I would advise to change this line from:

    $protocol = ( ! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https" : "http";

    to:

    $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http';
    
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘PHP Warnings when SERVER_PORT key is empty’ is closed to new replies.