Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#34164 closed defect (bug) (fixed)

Error during installation at step 1 - Undefined index: host

Reported by: jlambe's profile jlambe Owned by: swissspidy's profile swissspidy
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.0
Component: HTTP API Keywords: good-first-bug has-patch
Focuses: Cc:

Description

I've setup my local configuration to report all type of errors.

During a fresh installation of WordPress 4.3.1, at Step 1, WordPress triggers an error where the code tries to look at the array key host which is not yet defined.

The error seems to be in the following file: wp-includes/http.php on line 468

Here is a copy of the thrown exception:

Unhandled Exception

Message:

Undefined index: host
Location:

*/wp-includes/http.php on line 468

Attachments (2)

34164.diff (477 bytes) - added by perezlabs 9 years ago.
Added a simple patch based on the solution of @ramonxd and it works well.
34164.1.diff (655 bytes) - added by perezlabs 9 years ago.

Download all attachments as: .zip

Change History (18)

#1 @jeremyfelt
9 years ago

  • Keywords reporter-feedback added
  • Version trunk deleted

Hi @jlambe, thanks for the ticket. I'm not able to confirm any issues in trunk with a fresh install of WordPress and no plugins.

Can you provide steps to replicate the issue?

#2 follow-up: @jlambe
9 years ago

Hi @jeremyfelt,

I haven't tested again yet but I have reports that the issue happens only when you choose a language different than default english.

#3 in reply to: ↑ 2 @ramonxd
9 years ago

Replying to jlambe:

Hi @jeremyfelt,

I haven't tested again yet but I have reports that the issue happens only when you choose a language different than default english.

As @jlambe said, I'm getting the same error when I choose a different language than english.

Version 0, edited 9 years ago by ramonxd (next)

#4 @ramonxd
9 years ago

PS: I changed the 466 line in http.php and got it working, even w/ another languages.

//OLD
$same_host = strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] );

//NEW
$same_host = strtolower( $parsed_url['host'] );

#5 @jeremyfelt
9 years ago

  • Keywords needs-patch good-first-bug added; reporter-feedback removed
  • Milestone changed from Awaiting Review to Future Release
  • Version set to 4.0

Thanks for the additional info. I'm able to replicate this as well, not sure why the notice wasn't showing before.

When another language is selected during installation, an HTTP request is made to retrieve the language pack. In wp_http_validate_url() we check the host of the URL against the host of the current site to see if it an external request that requires additional validation. We don't take currently take into consideration that no host has been set for the current site yet, so that comparison generates a notice.

A similar issue was fixed via #28648 in [28865]. We should treat this similarly and mark the URL as an external host if no host has yet been set.

@perezlabs
9 years ago

Added a simple patch based on the solution of @ramonxd and it works well.

#6 @perezlabs
9 years ago

  • Keywords has-patch added; needs-patch removed

#7 @jeremyfelt
9 years ago

  • Keywords needs-patch added; has-patch removed

Thanks for the patch @perezlabs. We'll want to keep the comparison between the site's host and the host being parsed. If one is available, it needs to be checked properly. See [28865] for an example approach. If the host is available, check it. If the host is not available, assume it is an external URL.

#8 @perezlabs
9 years ago

Thanks for the feedback @jeremyfelt.

@perezlabs
9 years ago

#9 @perezlabs
9 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

#10 @swissspidy
9 years ago

  • Owner set to perezlabs
  • Status changed from new to assigned

Marking the good first bug as claimed.

#11 @perezlabs
9 years ago

  • Keywords needs-testing removed

#12 @swissspidy
9 years ago

  • Milestone changed from Future Release to 4.5

#13 @swissspidy
9 years ago

@jeremyfelt Happy to commit this if it looks good to you :)

#14 @swissspidy
9 years ago

  • Owner changed from perezlabs to swissspidy
  • Status changed from assigned to reviewing

#15 @swissspidy
9 years ago

  • Component changed from Upgrade/Install to HTTP API

#16 @swissspidy
9 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 36870:

HTTP: Avoid an undefined index notice in wp_http_validate_url().

Props perezlabs.
Fixes #34164.

Note: See TracTickets for help on using tickets.