Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#18051 closed defect (bug) (fixed)

Automatic updates fail if PHP/Mysql versions contain spaces

Reported by: vtd Owned by: dd32
Priority: normal Milestone: 3.3
Component: Upgrade/Install Version: 3.2
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

If the URL for checking for updates includes spaces (it does if PHP version is "5.2.5 (x64)", for example), then the check for updates fails (

wp_remote_get($url, $options)

in update.php returns HTTP 400 Bad Request error, making automatic updates impossible (Wordpreess always says it's up to date). This can be fixed by processing PHP and MySQL versions with urlencode(), so the url-formation line in updater.php should look like his

$url = "http://api.wordpress.org/core/version-check/1.6/?version=".
urlencode($wp_version).
"&php=".urlencode($php_version).
"&locale=$locale&mysql=".urlencode($mysql_version).
"&local_package=$local_package&blogs=$num_blogs&users={$user_count['total_users']}&multisite_enabled=$multisite_enabled";

Attachments (1)

18051.diff​ (1.0 KB ) - added by kurtpayne 15 years ago.

Download all attachments as: .zip

Change History (10)

#1 @scribu
15 years ago

  • Cc nacin added
  • Milestone Awaiting Review → WordPress.org

#2 follow-up: @nacin
15 years ago

  • Milestone WordPress.org → Awaiting Review

Not a WP.org issue - looks like the HTTP API is choking.

#3 in reply to: ↑ 2 @sterlo
15 years ago

Example:

Before:
string(171) "http://api.wordpress.org/core/version-check/1.6/?version=3.3-aortic-dissection&php=5.2.5 (x64)&locale=en_US&mysql=5.1.51&local_package=&blogs=1&users=1&multisite_enabled=0"

After:
string(175) "http://api.wordpress.org/core/version-check/1.6/?version=3.3-aortic-dissection&php=5.2.5+%28x64%29&locale=en_US&mysql=5.1.51&local_package=&blogs=1&users=1&multisite_enabled=0"

#4 follow-up: @dd32
15 years ago

Indeed the HTTP API isn't behaving like browsers, it's making the request directly with the url passed to it, whilst browsers do a bit of urlencoding over the contents if it sees anything unencoded.

the urlencode() addition here to the update check seems like the most appropriate response.

#5 @SergeyBiryukov
15 years ago

  • Keywords needs-patch added

@kurtpayne
15 years ago

#6 in reply to: ↑ 4 @kurtpayne
15 years ago

  • Cc kpayne@… added

Replying to dd32:

the urlencode() addition here to the update check seems like the most appropriate response.

Are you looking for something like 18051.diff​?

#7 @dd32
15 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone Awaiting Review → 3.3

#8 @dd32
15 years ago

Are you looking for something like 18051.diff

Not what I had in mind, but certainly a better option.

I had to alter it a bit however (certain servers are configured to have & as the separator, which would've broken the URL)

#9 @dd32
15 years ago

  • Owner set to dd32
  • Resolution → fixed
  • Status new → closed

In [18697]:

Use http_build_query in the Core Update check to encode version numbers. Props kurtpayne. Fixes #18051

Note: See TracTickets for help on using tickets.