[wp-trac] [WordPress Trac] #11136: Media upload tabs broken if not deployed in root
WordPress Trac
wp-trac at lists.automattic.com
Fri Mar 26 21:57:08 UTC 2010
#11136: Media upload tabs broken if not deployed in root
-------------------------------+--------------------------------------------
Reporter: s3000xl | Owner:
Type: defect (bug) | Status: reopened
Priority: normal | Milestone:
Component: Upload | Version:
Severity: normal | Resolution:
Keywords: reporter-feedback |
-------------------------------+--------------------------------------------
Changes (by jclarkcutler):
* status: closed => reopened
* resolution: worksforme =>
Comment:
I encountered this problem as well. I performed the following fix to my
own codebase, but I am new to PHP and WordPress so I encourage more
experienced users/developers to review the change:
On line 81 of wp-admin/includes/media.php, I added admin_url('media-
upload.php') as the oldquery_or_uri for add_query_arg. That is, I changed
the code from
$href = add_query_arg(array('tab'=>$callback, 's'=>false,
'paged'=>false, 'post_mime_type'=>false, 'm'=>false));
to
$href = add_query_arg(array('tab'=>$callback, 's'=>false,
'paged'=>false, 'post_mime_type'=>false, 'm'=>false), admin_url('media-
upload.php'));
From what I gather, the problem occurs when an intermediate server proxies
a non-root URL to another server powering WordPress. When add_query_arg()
is called without the final arg oldquery_or_uri, $_SERVER['REQUEST_URI']
is used as the base URL. This won't include the non-root portion of the
URL, however, which was stripped by the proxy server before sending the
request to the upstream server. (When WordPress is installed as a
traditional/real subdirectory of a server there shouldn't be a problem
because no portion of the REQUEST_URI gets stripped.)
For example, suppose www.example.com is handled by a proxy server
configured to direct requests for /blog to a custom-compiled server:
A client clicks the "Add an Image" button on the "Edit Post" page, issuing
a request to www.example.com/blog/wp-admin/media-upload.php?<...>.
The request to www.example.com/blog/wp-admin/media-upload.php?<...> is
handled by the proxy server.
The proxy server sends a request for /wp-admin/media-upload.php?<...> to
the custom server.
In generating a response, add_query_arg uses the REQUEST_URI to build a
link that points to www.example.com/wp-admin/media-upload.php?<...>.
This is *incorrect*; the /blog component of the path is missing. However,
if the user has appropriately set the URLs for home and siteurl,
admin_url() will include the subdirectory component as desired.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/11136#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list