WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#10234 closed defect (bug) (maybelater)

SunOS $REQUEST_URI issues breaking install/upgrade

Reported by: SteveBooth Owned by: markjaquith
Milestone: Priority: normal
Severity: major Version:
Component: Canonical Keywords: needs-patch
Focuses: Cc:

Description (last modified by westi)

Symptom:

After upgrading (or attempting) to 2.8.1, when browsing to <my wp site>/wp-admin, the system improperly re-directed to '<my wp site>?step=2/wp-admin/upgrade.php?_wp_http_referer='

This was caused by a prior step (unable to determine which) in the wp upgrade process placing the string '<my wp site>?step=2' in the 'wp_options' table in the database, thus destroying all references to the site because admin_url will then create incorrect references.

This is because on SunOS it doesn't populate REQUEST_URI instead you get the following:

    REQUEST_URI: (i.e. Null)
    SCRIPT_NAME: /wordpress/index.php
    PHP_SELF: /wordpress/index.php
    SERVER_NAME: stevenmbooth.com
}}]

Change History (21)

#1 @SteveBooth
11 years ago

I just noticed... In addition to the above, there are more missing components to the value stored in the database. the original string was:

<my wp site>?step=2

It should have been:

<my wp site>/wordpress

So the value placed in the DB was doubly wrong: It was missing a directory and had extraneous characters at the end.

#2 @SteveBooth
11 years ago

Further info:

So I gave up on the 2.8.1 install, and decided to try 2.7.1.

Same thing happened. The target install directory was http://stevenmbooth.com/wordpress. I did a completely normal install operation by browsing to stevenmbooth.com/wordpress/wp-admin.

The install process put 'http://www.stevenmbooth.com?step=2' in the wp_options table, and now I'm getting a 501 error when I try to log-in. <sigh>.

#3 @Denis-de-Bernardy
11 years ago

  • Milestone changed from Unassigned to 2.8.1
  • Severity changed from major to blocker

#4 @ryan
11 years ago

Are you using any caching backends like memcached or APC?

#5 @ryan
11 years ago

After fixing an install problem with [11623], I had no problems creating a fresh 2.8.1 blog with an address of stevenmbooth.com/wordpress (I mapped stevenmbooth.com to localhost for testing). 2.7.1 was also fine.

#6 @SteveBooth
11 years ago

I figured it out, and it's REALLY arcane. Get some Coke.. this is going to take a bit.

When the root index.php file runs, it requires blog-header.php. When this runs, it requires 'template-loader.php. Line 7 in 'template-loader.php' which is very nearly the first thing this module does is:

do_action('template_redirect');

This calls 'redirect_canonical' in canonical.php. No $args have been set up for the template_redirect and the $requested_url parameter to this function is null.

This causes the following code, on line 45, to execute:

if ( !$requested_url ) {

build the URL in the address bar
$requested_url = ( !empty($_SERVERHTTPS? ) &&

strtolower($_SERVERHTTPS?) == 'on' ) ? 'https://' : 'http://';

$requested_url .= $_SERVERHTTP_HOST?;
$requested_url .= $_SERVERREQUEST_URI?;

}

And herein lies the problem. My site is hosted on a Concentric Unix server. PHPInfo returns the following:

PHP Version 4.4.8
System: SunOS www.stevenmbooth.com 5.10 VDE sun4v
(MySQL is 4.1.22, but it's not germaine here)

And here's the bottom line. My wordpress home directory is 'http://www.stevenmbooth.com/wordpress'. $_SERVERHTTP_HOST?, above, returns 'www.stevenmbooth.com' and '$_SERVERREQUEST_URI?' returns null, and this produces The INCORRECT PATH.

These results cause the above code to construct the url 'http://www.stevenmbooth.com' as the redirect URL, and the browser immediately redirects to my root page, which causes my old index.html web site to initialize (I'm installing the WP site in the directory stevenmbooth.com/wordpress'.

SO... Either that redirect line at the beginning of template_loader is completely wrong (doubtful), or we need to use something other than HTTP_HOST to detect the root directory for WP (see http://www.nabble.com/When-HTTP_HOST-does-not-point-to-the-blog-td18097138.html ).

OH.. and I do believe this is a problem in 2.8.x as well, and that's why 2.8.x doesn't work for me.

So, you see, the problem was actually with WP's interaction with my Apache server, and not my site or my templates.

The question is... what do we do to fix this? What's the right way to detect the home install directory for WP? Assuming it's HTTP_HOST seems to be incorrect, here.

Geez. I wish I could charge you for the 12 hours it's taken me to find this.

:)

Steve

#7 @SteveBooth
11 years ago

Geez the code in canonical.php didnt post at all right. let me try that again. Here's at line 45:

if ( !$requested_url ) {

build the URL in the address bar
$requested_url = ( !empty($_SERVERHTTPS? ) &&

strtolower($_SERVERHTTPS?) == 'on' ) ? 'https://' : 'http://';

$requested_url .= $_SERVERHTTP_HOST?;
$requested_url .= $_SERVERREQUEST_URI?;

}

#8 @SteveBooth
11 years ago

Okay, sorry... the forum poster doesn't like single quotes much... plz refer to the source file for actual code representation.

#9 @dd32
11 years ago

Heres the code for others:

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

if $_SERVER['REQUEST_URI'] is empty, wp-settings.php fills it, You might want to take a look at the code for that in there and see if you can see anything overwriting it. The only real changes i see to that code are enhancements for IIS.

#10 @SteveBooth
11 years ago

Yes, thank you dd. I'm fairly new to the boards and missed the 'Code Block' icon in the WikiFormatting bar.

#11 @SteveBooth
11 years ago

Is there some reason we're not just using get_option('home')here? As in:

if ( !$requested_url ) {
     // build the URL in the address bar
     $requested_url  = ( !empty($_SERVER['HTTPS'] ) &&
        strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
     $requested_url .= get_option('home');
     $requested_url .= $_SERVER['REQUEST_URI'];
   }

I mean... the database is supposed to have the guaranteed correct path to the site -- that *is* what the 'home' option is for, isn't it?

S

#12 @ryan
11 years ago

get_option('home') . $_SERVERREQUEST_URI? could result in something like http://blog.foo/wp/wp/index.php

#13 @ryan
11 years ago

But the example at that link might work, where parse_url() is used.

#14 @ryan
11 years ago

  • Component changed from Upgrade/Install to Canonical
  • Owner changed from dd32 to markjaquith
  • Status changed from new to assigned

#15 @SteveBooth
11 years ago

Further info: This is caused by weirdnesses in the $SYSTEM variables on my host ISP server, which is running SunOS.These are the values when running the WP root index.php:

    REQUEST_URI: (i.e. Null)
    SCRIPT_NAME: /wordpress/index.php
    PHP_SELF: /wordpress/index.php
    SERVER_NAME: stevenmbooth.com

The installer is going to have a real problem with this. In fact, I'm in the middle of *trying* to install bbPress, and frankly it's been a nightmare, trying to get it to even run on this platform. To get at least a fairly reasonable value into REQUEST URI, I inserted the following code into bb_load.php:

	// On some SunOS/Solarix systems, we need to construct the path from 
	// the SERVER_NAME and the SCRIPT_NAME:
	if ( !isset($_SERVER['PATH_INFO']) && 
	      isset($_SERVER['SERVER_NAME']) &&
	      isset($_SERVER['SCRIPT_NAME']) ) {
		$_SERVER['PATH_INFO'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
		$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
	}

I suspect a similar thing needs to be done for WP.

#16 @westi
11 years ago

  • Cc westi added
  • Description modified (diff)
  • Milestone changed from 2.8.1 to 2.8.2
  • Severity changed from blocker to major
  • Summary changed from Incorrect 'siteurl' inserted into database to SunOS $REQUEST_URI issues breaking install/upgrade

Updating description and moving to 2.9 for now as 2.8.1 is about to be released and I don't believe this is a regression.

Once we have a working fix we can consider a backport to 2.8 branch for a later 2.8.x release.

#17 @markjaquith
11 years ago

  • Milestone changed from 2.9 to 3.0

No patch. Who wants to take this for 3.0?

#18 @dd32
10 years ago

  • Keywords needs-patch added

Still no patch, Anyone have time to duplicate it on their environment before beta sneaks up and its too late again?

#19 @dd32
10 years ago

  • Milestone changed from 3.0 to Future Release

Moving to Future release pending patch & testing.

#20 @ramoonus
10 years ago

anyone tried if this bug is still present in 3.1?

#21 @dd32
10 years ago

  • Milestone Future Release deleted
  • Resolution set to maybelater
  • Status changed from assigned to closed

Closing as maybelater, If someone can come up with a patch, feel free to re-open this ticket

Note: See TracTickets for help on using tickets.