Support » Fixing WordPress » Undefined index: host in /var/www/wordpress/wp-includes/canonical.php

  • Running an e-com site which seems okay until I try to update products or images using AliDropship Woo. At this point, it shows to go down and reports HTTP 500 or 503 briefly before allowing me to access again. I reinstalled WP, deactivated all plug-ins and set a default theme and found this repeating in the debug.log:

    [11-Dec-2019 02:10:47 UTC] PHP Notice: Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 528
    [11-Dec-2019 02:10:47 UTC] PHP Notice: Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 528
    [11-Dec-2019 02:10:47 UTC] PHP Notice: Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 530

    After reactivating all my settings, debug.log looks like:

    [11-Dec-2019 02:33:09 UTC] PHP Notice: Undefined index: scheme in /var/www/wordpress/wp-includes/canonical.php on line 554
    [11-Dec-2019 02:33:09 UTC] PHP Notice: Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 528
    [11-Dec-2019 02:33:09 UTC] PHP Notice: Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 528
    [11-Dec-2019 02:33:09 UTC] PHP Notice: Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 530
    [11-Dec-2019 02:33:09 UTC] PHP Notice: Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 533
    [11-Dec-2019 02:33:09 UTC] PHP Notice: Undefined index: scheme in /var/www/wordpress/wp-includes/canonical.php on line 554

    • This topic was modified 1 month, 1 week ago by whitewolfha.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 19 total)
  • Configure your htaccess with RewriteCond if the HTTP_HOST variable does not exist, create it with SetEnv.
    Actually you should set up a basic domain (and create the HTTP_HOST variable for that base domain).

    You can captured $original linea 553 add this?

    function var_x_error_log( $objectauto=null){
    ob_start(); // start buffer capture
    var_dump($objectauto); // dump the value
    $contentsauto = ob_get_contents(); // put the buffer into a variable
    ob_end_clean(); // end capture
    error_log( $contentsauto,3,dirname(__FILE__).'/test.log'); // log contents of the result of var_dump( $objectauto)
    }
    var_x_error_log($original);

    Now change with $compare_redirect
    this crete test.log into current directory

    Thank you for the response. I apologize but I have very limited understanding of this. I tried to copy & past the above code into my htcaccess but the immediately received a http 503 so I backed it out. I have a different site on ‘wwolf.us’ so want this to run on this sub.

    Here is my htcaccess:

    # BEGIN WordPress
    # The directives (lines) between <code>BEGIN WordPress</code> and <code>END WordPress</code> are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Sorry I thought it was clear to place my code two lines before the error, enter it before this line. https://github.com/WordPress/WordPress/blob/5.3-branch/wp-includes/canonical.php#L553
    What does sub mean, please write the whole domain.
    It is not possible to make requests other than http://www.domain1.com when you use them http://www.domain2.com

    Sorry, I did not understand that. My full address is https://shop.wwolf.us

    I plugged it in and was unable to access the site at all. Found this error in the debug.log:

    [12-Dec-2019 00:18:16 UTC] PHP Notice:  Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 528
    [12-Dec-2019 00:18:16 UTC] PHP Notice:  Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 528
    [12-Dec-2019 00:18:16 UTC] PHP Notice:  Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 530
    [12-Dec-2019 00:18:16 UTC] PHP Notice:  Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 533
    [12-Dec-2019 00:18:16 UTC] PHP Notice:  Undefined index: scheme in /var/www/wordpress/wp-includes/canonical.php on line 561
    [12-Dec-2019 00:18:16 UTC] PHP Notice:  Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 528
    [12-Dec-2019 00:18:16 UTC] PHP Notice:  Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 528
    [12-Dec-2019 00:18:16 UTC] PHP Notice:  Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 530
    [12-Dec-2019 00:18:16 UTC] PHP Notice:  Undefined index: host in /var/www/wordpress/wp-includes/canonical.php on line 533
    [12-Dec-2019 00:18:16 UTC] PHP Fatal error:  Cannot redeclare var_x_error_log() (previously declared in /var/www/wordpress/wp-includes/canonical.php:552) in /var/www/wordpress/wp-includes/canonical.php on line 552
    	if ( ! empty( $redirect['query'] ) ) {
    		$compare_redirect[] = $redirect['query'];
    	}
    
    	function var_x_error_log( $objectauto=null){
    ob_start(); // start buffer capture
    var_dump($objectauto); // dump the value
    $contentsauto = ob_get_contents(); // put the buffer into a variable
    ob_end_clean(); // end capture
    error_log( $contentsauto,3,dirname(__FILE__).'/test.log'); // log contents of the result of var_dump( $objectauto)
    }
    var_x_error_log($original);
    
    	if ( $compare_original !== $compare_redirect ) {
    		$redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
    		if ( ! empty( $redirect['port'] ) ) {
    			$redirect_url .= ':' . $redirect['port'];
    		}
    		$redirect_url .= $redirect['path'];
    		if ( ! empty( $redirect['query'] ) ) {
    			$redirect_url .= '?' . $redirect['query'];
    		}
    	}
    
    	if ( ! $redirect_url || $redirect_url == $requested_url ) {
    		return;
    • This reply was modified 1 month, 1 week ago by whitewolfha.

    if you entered my code in wp-content/wp-includes/canonical.php (line 531 for missing host) create a file in wp-content/wp-includes/test.log
    Please report the content

     else {
    if(!function_exists('var_x_error_log')) {
    function var_x_error_log( $objectauto=null){
    ob_start(); // start buffer capture
    var_dump($objectauto); // dump the value
    $contentsauto = ob_get_contents(); // put the buffer into a variable
    ob_end_clean(); // end capture
    error_log( $contentsauto,3,dirname(__FILE__).'/test.log'); // log contents of the result of var_dump( $objectauto)
    }
    var_x_error_log($original);
    }
    }

    Sorry for this issue.

    It repeats the following code:

    array(1) {
      ["path"]=>
      string(0) ""
    }
    array(1) {
      ["path"]=>
      string(0) ""
    }
    array(1) {
      ["path"]=>
      string(0) ""
    }

    elima test.log, execute the new indications.

    I apologize for my ignorance but what does that mean?

    elima test.log –> remove the added code?

    execute the new indications –> what is and where do I execute the new indication?

    Sorry, I updated the code and how to use it, you can repeat.
    Even if you don’t repeat my code there is a problem with the host field, is a http_host header sent?
    Can I provide you with the code to add the host field?

    if(!isset($_SERVER['HTTP_HOST'])) {
    $_SERVER['HTTP_HOST'] = 'shop.wwolf.us';
    }

    https://github.com/WordPress/WordPress/blob/5.3-branch/wp-includes/canonical.php#L62 line 62

    • This reply was modified 1 month, 1 week ago by autotutorial.

    Please provide anything you feel would help.

    I believe they are getting host header. I have the below configured in haproxy for this backend:

    req.hdr(X-Forwarded-Host) -m found
    X-Forwarded-Host, fmt: %[req.hdr(Host)]

    I think that did something right. The original error is gone when I access products (and updates) but now getting a new error.

    [12-Dec-2019 02:17:47 UTC] PHP Warning:  _() expects exactly 1 parameter, 2 given in /var/www/wordpress/wp-content/plugins/alidswoo/includes/adsw/update/uploadExternalImages.php on line 0
    [12-Dec-2019 02:17:47 UTC] PHP Warning:  _() expects exactly 1 parameter, 2 given in /var/www/wordpress/wp-content/plugins/alidswoo/includes/adsw/update/uploadExternalImages.php on line 0
    [12-Dec-2019 02:17:48 UTC] PHP Warning:  _() expects exactly 1 parameter, 2 given in /var/www/wordpress/wp-content/plugins/alidswoo/includes/adsw/update/uploadExternalImages.php on line 0
    [12-Dec-2019 02:17:48 UTC] PHP Warning:  _() expects exactly 1 parameter, 2 given in /var/www/wordpress/wp-content/plugins/alidswoo/includes/adsw/update/uploadExternalImages.php on line 0

    and

    [12-Dec-2019 02:22:08 UTC] PHP Notice: Undefined index: _sku in /var/www/wordpress/wp-content/plugins/alidswoo/includes/Ali/AliImport.php on line 0

    For header host is a bug on wordpress, you can report here https://core.trac.wordpress.org/ .
    You’re using a commercial plugin so I have no way to check the plugin code. can you search with google where to request support for your plugin?
    I am documenting for your proxy if I have news I am writing here.

    Thank you! I will start searching for info on the alidswoo.

    option httpchk HEAD / HTTP/1.1\r\nHost:localhost – Set the health check HAProxy uses to test if the web servers are still responding. If these fail to respond without error, the server is removed from HAProxy as one to load balance between. This sends a HEAD request with the HTTP/1.1 and Host header set, which might be needed if your web server uses virtualhosts to detect which site to send traffic to

    https://serversforhackers.com/c/load-balancing-with-haproxy

    __() this function have two parameter (For WordPress core) https://developer.wordpress.org/reference/functions/__/ https://github.com/WordPress/WordPress/blob/5.3-branch/wp-includes/l10n.php#L254

    WOW – that made a huge difference, at least so far. I am still getting the errors but now my site does not show to be dropping off. Thank you so much.

    I had it set to GET which is how I have other non-WP sites. Makes me winder if I should change them.

Viewing 15 replies - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.