Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#32229 closed defect (bug) (fixed)

redirect_canonical - Undefined Index HTTP_HOST

Reported by: howdy_mcgee's profile Howdy_McGee Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.2.1
Component: Canonical Keywords: has-patch commit
Focuses: administration Cc:

Description

One of my more popular installs is getting its debug.log blasted with notices:

PHP Notice:  Undefined index: HTTP_HOST in /wp-includes/canonical.php on line 63

Which is in this conditional block of redirect_canonical

if ( !$requested_url ) {
	// build the URL in the address bar
	$requested_url  = is_ssl() ? 'https://' : 'http://';
	$requested_url .= $_SERVER['HTTP_HOST'];
	$requested_url .= $_SERVER['REQUEST_URI'];
}

This is more than likely being generated by bots hitting pages that no longer exist or have never existed. I created a support topic on the issue which then was told to create a ticket. I believe my 2nd notice ( in the support question ) is also related.

Attachments (1)

32229.patch (1.2 KB) - added by SergeyBiryukov 9 years ago.

Download all attachments as: .zip

Change History (7)

#1 @Howdy_McGee
10 years ago

  • Focuses accessibility removed

#2 @Howdy_McGee
10 years ago

I've also created a debug_backtrace of the issue incase it's any help:

Array
(
    [0] => Array
        (
            [function] => redirect_canonical
            [args] => Array
                (
                    [0] => 
                )
        )

    [1] => Array
        (
            [file] => /httpdocs/wp-includes/plugin.php
            [line] => 496
            [function] => call_user_func_array
            [args] => Array
                (
                    [0] => redirect_canonical
                    [1] => Array
                        (
                            [0] => 
                        )
                )
        )

    [2] => Array
        (
            [file] => /httpdocs/wp-includes/template-loader.php
            [line] => 12
            [function] => do_action
            [args] => Array
                (
                    [0] => template_redirect
                )
        )

    [3] => Array
        (
            [file] => /httpdocs/wp-blog-header.php
            [line] => 16
            [args] => Array
                (
                    [0] => /httpdocs/wp-includes/template-loader.php
                )
            [function] => require_once
        )

    [4] => Array
        (
            [file] => /httpdocs/index.php
            [line] => 17
            [args] => Array
                (
                    [0] => /httpdocs/wp-blog-header.php
                )
            [function] => require
        )
)

Also a related bug:

PHP Notice: Undefined index: HTTP_HOST in /httpdocs/wp-includes/nav-menu-template.php on line 549

If need be I can create a debug_backtrace on that too.

#3 @SergeyBiryukov
9 years ago

  • Milestone changed from Awaiting Review to 4.4

#4 @SergeyBiryukov
9 years ago

  • Keywords has-patch commit added

#5 @SergeyBiryukov
9 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 33775:

Avoid PHP notices in redirect_canonical() and _wp_menu_item_classes_by_context() if $_SERVER['HTTP_HOST'] is not set.

fixes #32229.

#6 @swissspidy
9 years ago

#34353 was marked as a duplicate.

Note: See TracTickets for help on using tickets.