[wp-trac] [WordPress Trac] #13483: fileupload_url / upload_url_path
WordPress Trac
wp-trac at lists.automattic.com
Fri May 21 23:52:18 UTC 2010
#13483: fileupload_url / upload_url_path
--------------------------+-------------------------------------------------
Reporter: jimisaacs | Owner:
Type: defect (bug) | Status: new
Priority: high | Milestone: 3.0
Component: Multisite | Version: 3.0
Severity: major | Keywords: multisite attachments fileupload_url upload_url_path
--------------------------+-------------------------------------------------
Comment(by jimisaacs):
Well the problem seemed to be with this conditional in both if statements
in wp_upload_dir()
if ( defined('UPLOADS') && ( !$main_override || WP_CONTENT_DIR .
'/uploads' != ABSPATH . $upload_path ) && ( !isset( $switched ) ||
$switched === true ) ) {
if ( is_multisite() && ( !$main_override || WP_CONTENT_DIR . '/uploads' !=
ABSPATH . $upload_path ) && ( !isset( $switched ) || $switched === true )
) {
In particular:
&& ( !isset( $switched ) || $switched === false )
I took a long hard look at this I realized this is the check to see if we
just ran switch_to_blog() and wondered why is was checking for "false
With this logic, what I was seeing is this
IF "'Is a multisite' AND 'not overriding the main site' AND 'NOT
switched'" --- then change the url
That didn't make sense, we do want to override if switched right?
What I thought it should be is:
if ( is_multisite() && ( !$main_override || WP_CONTENT_DIR . '/uploads' !=
ABSPATH . $upload_path ) && ( !isset( $switched ) || $switched === true )
) {
and the final code is:
$override = (( !$main_override || WP_CONTENT_DIR . '/uploads' != ABSPATH .
$upload_path ) && $switched === true);
if ( defined('UPLOADS') && $override ) {
$dir = ABSPATH . UPLOADS;
$url = trailingslashit( $siteurl ) . UPLOADS;
}
if ( is_multisite() && $override ) {
if ( defined( 'BLOGUPLOADDIR' ) )
$dir = untrailingslashit(BLOGUPLOADDIR);
$url = str_replace( UPLOADS, 'files', $url );
}
This of course worked for the problem I was having. Please let me know
what this looks like... I could be completely wrong on this because I'm
seeing a lot of stuff in the code that looks like wordpress is preparing
for something larger than multisite, multiserver maybe?
Basically, I am wondering if I should be be using switch_to_blog? Is there
a replacement I should be using?
Thanks,
Jim
--
Ticket URL: <http://core.trac.wordpress.org/ticket/13483#comment:13>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list