[wp-trac] [WordPress Trac] #4732: $guessurl wrong in install.php

WordPress Trac wp-trac at lists.automattic.com
Sun Aug 12 13:15:44 GMT 2007


#4732: $guessurl wrong in install.php
----------------------------+-----------------------------------------------
 Reporter:  ar0n            |       Owner:  anonymous             
     Type:  defect          |      Status:  new                   
 Priority:  normal          |   Milestone:  2.2.3                 
Component:  Administration  |     Version:  2.2                   
 Severity:  major           |    Keywords:  $guessurl  install.php
----------------------------+-----------------------------------------------
 Apache >1.3 has a function implemented that gets the real uri named
 original_uri() (util_script.c).

 Let's say wordpress is located at http://example.com/wordpress .

 ''A standard request looks like this:''
 {{{
 GET /wordpress/wp-admin/install.php HTTP/1.1
 }}}
 Okey ... now apache original_uri(r) returns /wp-admin/index.php
 So PHP global variable $_SERVER[ 'REQUEST_URI' ]; looks like "/wp-
 admin/index.php"

 ''upgrade-functions.php , upgrade-schema.php:''
 {{{
 $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema .
 $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
 }}}

 $guessurl is "http://example.com/wordpress" cool :)


 ----


 But what if the request is forwarded by squid with default config in accel
 vhost mode.

 Here goes ...

 ''The request is:''
 {{{
 GET http:///example.com/wordpress/wp-admin/install.php HTTP/1.1
 }}}
 Apache original_uri(r) returns http:///example.com/wordpress/wp-
 admin/install.php which is legal.

 PHP global variable $_SERVER["REQUEST_URI"] is
 "http:///example.com/wordpress/wp-admin/install.php"

 ''upgrade-functions.php , upgrade-schema.php:''
 {{{
 $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema .
 $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
 }}}

 $guessurl is "http://example.comhttp://example.com/wordpress" not cool :(

 The problem with this that values 'siteurl' and 'home' will be wrong in
 the options table.

 ''This code solves the problem (replaceing it in both places):''
 {{{
 $guessurl = eregi($schema . $_SERVER['HTTP_HOST'],
 $_SERVER['REQUEST_URI']) ? preg_replace('|/wp-admin/.*|i', '',
 $_SERVER['REQUEST_URI']) : preg_replace('|/wp-admin/.*|i', '', $schema .
 $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
 }}}

 APACHE: v2.2.4
 OS: BSD
 PHP: 5.2.4RC1-dev
 SQUID: 2.6

 Yours,
 Aron Szabo

-- 
Ticket URL: <http://trac.wordpress.org/ticket/4732>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list