<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[21823] trunk: Remove ms-files.php rewriting from WordPress multisite.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/21823">21823</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-09-11 22:22:20 +0000 (Tue, 11 Sep 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Remove ms-files.php rewriting from WordPress multisite. fixes <a href="http://core.trac.wordpress.org/ticket/19235">#19235</a>.
Keep existing networks compatible with a ms_files_rewriting network option.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesmsdeprecatedphp">trunk/wp-admin/includes/ms-deprecated.php</a></li>
<li><a href="#trunkwpadminincludesmsphp">trunk/wp-admin/includes/ms.php</a></li>
<li><a href="#trunkwpadminincludesschemaphp">trunk/wp-admin/includes/schema.php</a></li>
<li><a href="#trunkwpadminincludesupgradephp">trunk/wp-admin/includes/upgrade.php</a></li>
<li><a href="#trunkwpadminnetworkphp">trunk/wp-admin/network.php</a></li>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
<li><a href="#trunkwpincludesmsdefaultconstantsphp">trunk/wp-includes/ms-default-constants.php</a></li>
<li><a href="#trunkwpincludesmsdefaultfiltersphp">trunk/wp-includes/ms-default-filters.php</a></li>
<li><a href="#trunkwpincludesmsfunctionsphp">trunk/wp-includes/ms-functions.php</a></li>
<li><a href="#trunkwpincludesoptionphp">trunk/wp-includes/option.php</a></li>
<li><a href="#trunkwpincludesrewritephp">trunk/wp-includes/rewrite.php</a></li>
<li><a href="#trunkwpincludesversionphp">trunk/wp-includes/version.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesmsdeprecatedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/ms-deprecated.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/ms-deprecated.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-admin/includes/ms-deprecated.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -73,4 +73,6 @@
</span><span class="cx"> function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
</span><span class="cx">         _deprecated_function( __FUNCTION__, '3.4', 'WP_Theme::get_allowed_on_site()' );
</span><span class="cx">         return array_map( 'intval', WP_Theme::get_allowed_on_site( $blog_id ) );
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+}
+
+function ms_deprecated_blogs_file() {}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminincludesmsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/ms.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/ms.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-admin/includes/ms.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -90,7 +90,8 @@
</span><span class="cx">
</span><span class="cx">                 $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
</span><span class="cx">
</span><del>-                $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );
</del><ins>+                $uploads = wp_upload_dir();
+                $dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
</ins><span class="cx">                 $dir = rtrim( $dir, DIRECTORY_SEPARATOR );
</span><span class="cx">                 $top_dir = $dir;
</span><span class="cx">                 $stack = array($dir);
</span><span class="lines">@@ -357,8 +358,10 @@
</span><span class="cx"> function get_space_used() {
</span><span class="cx">         // Allow for an alternative way of tracking storage space used
</span><span class="cx">         $space_used = apply_filters( 'pre_get_space_used', false );
</span><del>-        if ( false === $space_used )
-                $space_used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
</del><ins>+        if ( false === $space_used ) {
+                $upload_dir = wp_upload_dir();
+                $space_used = get_dirsize( $upload_dir['basedir'] ) / 1024 / 1024;
+        }
</ins><span class="cx">
</span><span class="cx">         return $space_used;
</span><span class="cx"> }
</span><span class="lines">@@ -682,15 +685,6 @@
</span><span class="cx">         <?php
</span><span class="cx"> }
</span><span class="cx">
</span><del>-function ms_deprecated_blogs_file() {
-        if ( ! is_super_admin() )
-                return;
-        if ( ! file_exists( WP_CONTENT_DIR . '/blogs.php' ) )
-                return;
-        echo '<div class="update-nag">' . sprintf( __( 'The <code>%1$s</code> file is deprecated. Please remove it and update your server rewrite rules to use <code>%2$s</code> instead.' ), 'wp-content/blogs.php', 'wp-includes/ms-files.php' ) . '</div>';
-}
-add_action( 'network_admin_notices', 'ms_deprecated_blogs_file' );
-
</del><span class="cx"> /**
</span><span class="cx"> * Grants super admin privileges.
</span><span class="cx"> *
</span></span></pre></div>
<a id="trunkwpadminincludesschemaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/schema.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/schema.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-admin/includes/schema.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -912,6 +912,7 @@
</span><span class="cx">                 'upload_space_check_disabled' => '0',
</span><span class="cx">                 'subdomain_install' => intval( $subdomain_install ),
</span><span class="cx">                 'global_terms_enabled' => global_terms_enabled() ? '1' : '0',
</span><ins>+                'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0',
</ins><span class="cx">                 'initial_db_version' => get_option( 'initial_db_version' ),
</span><span class="cx">                 'active_sitewide_plugins' => array(),
</span><span class="cx">         );
</span><span class="lines">@@ -940,11 +941,6 @@
</span><span class="cx">                 $blog_id = $wpdb->insert_id;
</span><span class="cx">                 update_user_meta( $site_user->ID, 'source_domain', $domain );
</span><span class="cx">                 update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
</span><del>-                if ( !$upload_path = get_option( 'upload_path' ) ) {
-                        $upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
-                        update_option( 'upload_path', $upload_path );
-                }
-                update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );
</del><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ( $subdomain_install )
</span></span></pre></div>
<a id="trunkwpadminincludesupgradephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/upgrade.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/upgrade.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-admin/includes/upgrade.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -1271,6 +1271,10 @@
</span><span class="cx">                         delete_site_option( 'allowed_themes' );
</span><span class="cx">                 }
</span><span class="cx">         }
</span><ins>+
+        // 3.5
+        if ( $wp_current_db_version < 21823 )
+                update_site_option( 'ms_files_rewriting', '1' );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // The functions we use to actually do stuff
</span></span></pre></div>
<a id="trunkwpadminnetworkphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-admin/network.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx"> $network_help = '<p>' . __('This screen allows you to configure a network as having subdomains (<code>site1.example.com</code>) or subdirectories (<code>example.com/site1</code>). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '</p>' .
</span><span class="cx">         '<p>' . __('Choose subdomains or subdirectories; this can only be switched afterwards by reconfiguring your install. Fill out the network details, and click install. If this does not work, you may have to add a wildcard DNS record (for subdomains) or change to another setting in Permalinks (for subdirectories).') . '</p>' .
</span><span class="cx">         '<p>' . __('The next screen for Network Setup will give you individually-generated lines of code to add to your wp-config.php and .htaccess files. Make sure the settings of your FTP client make files starting with a dot visible, so that you can find .htaccess; you may have to create this file if it really is not there. Make backup copies of those two files.') . '</p>' .
</span><del>-        '<p>' . __('Add a <code>blogs.dir</code> directory under <code>/wp-content</code> and add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .
</del><ins>+        '<p>' . __('Add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .
</ins><span class="cx">         '<p>' . __('Once you add this code and refresh your browser, multisite should be enabled. This screen, now in the Network Admin navigation menu, will keep an archive of the added code. You can toggle between Network Admin and Site Admin by clicking on the Network Admin or an individual site name under the My Sites dropdown in the Toolbar.') . '</p>' .
</span><span class="cx">         '<p>' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with &#8220;/blog/&#8221; from the main site. This disabling will be addressed in a future version.') . '</p>' .
</span><span class="cx">         '<p><strong>' . __('For more information:') . '</strong></p>' .
</span><span class="lines">@@ -190,9 +190,6 @@
</span><span class="cx">                 $error_codes = $errors->get_error_codes();
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
-                echo '<div class="error"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
-
</del><span class="cx">         $site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
</span><span class="cx">         $admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' );
</span><span class="cx">         ?>
</span><span class="lines">@@ -235,6 +232,9 @@
</span><span class="cx"> <?php
</span><span class="cx">         endif;
</span><span class="cx">
</span><ins>+                if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) )
+                        echo '<div class="error inline"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
+
</ins><span class="cx">                 $is_www = ( 0 === strpos( $hostname, 'www.' ) );
</span><span class="cx">                 if ( $is_www ) :
</span><span class="cx">                 ?>
</span><span class="lines">@@ -360,11 +360,6 @@
</span><span class="cx">         }
</span><span class="cx"> ?>
</span><span class="cx">                 <ol>
</span><del>-                        <li><p><?php
-                                printf( __( 'Create a <code>blogs.dir</code> directory at <code>%s/blogs.dir</code>. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR );
-                                if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
-                                        echo ' <strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong>';
-                        ?></p></li>
</del><span class="cx">                         <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:' ), ABSPATH ); ?></p>
</span><span class="cx">                                 <textarea class="code" readonly="readonly" cols="100" rows="7">
</span><span class="cx"> define('MULTISITE', true);
</span><span class="lines">@@ -415,12 +410,16 @@
</span><span class="cx"> <rule name="WordPress Rule 1" stopProcessing="true">
</span><span class="cx"> <match url="^index\.php$" ignoreCase="false" />
</span><span class="cx"> <action type="None" />
</span><del>- </rule>
- <rule name="WordPress Rule 2" stopProcessing="true">
</del><ins>+ </rule>';
+                                if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
+                                        $web_config_file .= '
+ <rule name="WordPress Rule for Files" stopProcessing="true">
</ins><span class="cx"> <match url="^files/(.+)" ignoreCase="false" />
</span><span class="cx"> <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
</span><del>- </rule>
- <rule name="WordPress Rule 3" stopProcessing="true">
</del><ins>+ </rule>';
+ }
+ $web_config_file .= '
+ <rule name="WordPress Rule 2" stopProcessing="true">
</ins><span class="cx"> <match url="^" ignoreCase="false" />
</span><span class="cx"> <conditions logicalGrouping="MatchAny">
</span><span class="cx"> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
</span><span class="lines">@@ -428,7 +427,7 @@
</span><span class="cx"> </conditions>
</span><span class="cx"> <action type="None" />
</span><span class="cx"> </rule>
</span><del>- <rule name="WordPress Rule 4" stopProcessing="true">
</del><ins>+ <rule name="WordPress Rule 3" stopProcessing="true">
</ins><span class="cx"> <match url="." ignoreCase="false" />
</span><span class="cx"> <action type="Rewrite" url="index.php" />
</span><span class="cx"> </rule>
</span><span class="lines">@@ -446,16 +445,20 @@
</span><span class="cx"> <rule name="WordPress Rule 1" stopProcessing="true">
</span><span class="cx"> <match url="^index\.php$" ignoreCase="false" />
</span><span class="cx"> <action type="None" />
</span><del>- </rule>
</del><ins>+ </rule>';
+                                if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
+                                        $web_config_file .= '
+ <rule name="WordPress Rule for Files" stopProcessing="true">
+ <match url="^files/(.+)" ignoreCase="false" />
+ <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
+ </rule>';
+ }
+ $web_config_file .= '
</ins><span class="cx"> <rule name="WordPress Rule 2" stopProcessing="true">
</span><del>- <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
- <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
- </rule>
- <rule name="WordPress Rule 3" stopProcessing="true">
</del><span class="cx"> <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
</span><span class="cx"> <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
</span><span class="cx"> </rule>
</span><del>- <rule name="WordPress Rule 4" stopProcessing="true">
</del><ins>+ <rule name="WordPress Rule 3" stopProcessing="true">
</ins><span class="cx"> <match url="^" ignoreCase="false" />
</span><span class="cx"> <conditions logicalGrouping="MatchAny">
</span><span class="cx"> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
</span><span class="lines">@@ -463,15 +466,15 @@
</span><span class="cx"> </conditions>
</span><span class="cx"> <action type="None" />
</span><span class="cx"> </rule>
</span><del>- <rule name="WordPress Rule 5" stopProcessing="true">
</del><ins>+ <rule name="WordPress Rule 4" stopProcessing="true">
</ins><span class="cx"> <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
</span><span class="cx"> <action type="Rewrite" url="{R:1}" />
</span><span class="cx"> </rule>
</span><del>- <rule name="WordPress Rule 6" stopProcessing="true">
</del><ins>+ <rule name="WordPress Rule 5" stopProcessing="true">
</ins><span class="cx"> <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
</span><span class="cx"> <action type="Rewrite" url="{R:2}" />
</span><span class="cx"> </rule>
</span><del>- <rule name="WordPress Rule 7" stopProcessing="true">
</del><ins>+ <rule name="WordPress Rule 6" stopProcessing="true">
</ins><span class="cx"> <match url="." ignoreCase="false" />
</span><span class="cx"> <action type="Rewrite" url="index.php" />
</span><span class="cx"> </rule>
</span><span class="lines">@@ -482,8 +485,11 @@
</span><span class="cx">                         }
</span><span class="cx">         ?>
</span><span class="cx">                 <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
</span><del>-                <textarea class="code" readonly="readonly" cols="100" rows="20">
-                <?php echo esc_textarea( $web_config_file ); ?>
</del><ins>+                <?php
+                if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
+                        echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
+                ?>
+                <textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
</ins><span class="cx">                 </textarea></li>
</span><span class="cx">                 </ol>
</span><span class="cx">
</span><span class="lines">@@ -491,10 +497,12 @@
</span><span class="cx">
</span><span class="cx">                 $htaccess_file = 'RewriteEngine On
</span><span class="cx"> RewriteBase ' . $base . '
</span><del>-RewriteRule ^index\.php$ - [L]
</del><ins>+RewriteRule ^index\.php$ - [L]' . "\n";
</ins><span class="cx">
</span><del>-# uploaded files
-RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
</del><ins>+                if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
+                        $htaccess_file .= "\n# uploaded files\nRewriteRule ^";
+                        $htaccess_file .= ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
+                }
</ins><span class="cx">
</span><span class="cx">                 if ( ! $subdomain_install )
</span><span class="cx">                         $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
</span><span class="lines">@@ -511,7 +519,11 @@
</span><span class="cx">
</span><span class="cx">                 ?>
</span><span class="cx">                 <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
</span><del>-                <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">
</del><ins>+                <?php
+                if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
+                        echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
+                ?>
+                <textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
</ins><span class="cx"> <?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
</span><span class="cx">                 </ol>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-includes/functions.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -1432,21 +1432,16 @@
</span><span class="cx"> * @return array See above for description.
</span><span class="cx"> */
</span><span class="cx"> function wp_upload_dir( $time = null ) {
</span><del>-        global $_wp_switched;
</del><span class="cx">         $siteurl = get_option( 'siteurl' );
</span><del>-        $upload_path = get_option( 'upload_path' );
-        $upload_path = trim($upload_path);
-        $main_override = is_multisite() && defined( 'MULTISITE' ) && is_main_site();
-        if ( empty($upload_path) ) {
</del><ins>+        $upload_path = trim( get_option( 'upload_path' ) );
+
+        if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
</ins><span class="cx">                 $dir = WP_CONTENT_DIR . '/uploads';
</span><ins>+        } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) {
+                // $dir is absolute, $upload_path is (maybe) relative to ABSPATH
+                $dir = path_join( ABSPATH, $upload_path );
</ins><span class="cx">         } else {
</span><span class="cx">                 $dir = $upload_path;
</span><del>-                if ( 'wp-content/uploads' == $upload_path ) {
-                        $dir = WP_CONTENT_DIR . '/uploads';
-                } elseif ( 0 !== strpos($dir, ABSPATH) ) {
-                        // $dir is absolute, $upload_path is (maybe) relative to ABSPATH
-                        $dir = path_join( ABSPATH, $dir );
-                }
</del><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ( !$url = get_option( 'upload_url_path' ) ) {
</span><span class="lines">@@ -1456,15 +1451,24 @@
</span><span class="cx">                         $url = trailingslashit( $siteurl ) . $upload_path;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( defined('UPLOADS') && ! $main_override && ! $_wp_switched ) {
</del><ins>+        if ( defined( 'UPLOADS' ) ) {
</ins><span class="cx">                 $dir = ABSPATH . UPLOADS;
</span><span class="cx">                 $url = trailingslashit( $siteurl ) . UPLOADS;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( is_multisite() && ! $main_override && ! $_wp_switched ) {
-                if ( defined( 'BLOGUPLOADDIR' ) )
-                        $dir = untrailingslashit(BLOGUPLOADDIR);
-                $url = str_replace( UPLOADS, 'files', $url );
</del><ins>+        // Multisite (if not the main site in a post-MU network)
+        if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) ) {
+                if ( ! get_site_option( 'ms_files_rewriting' ) ) {
+                        // Append sites/%d if we're not on the main site (for post-MU networks).
+                        $ms_dir = '/sites/' . get_current_blog_id();
+                        $dir .= $ms_dir;
+                        $url .= $ms_dir;
+                } elseif ( ! ms_is_switched() ) {
+                        // Handle the old-form ms-files.php rewriting if the network still has that enabled.
+                        if ( defined( 'BLOGUPLOADDIR' ) )
+                                $dir = untrailingslashit( BLOGUPLOADDIR );
+                        $url = str_replace( UPLOADS, 'files', $url );
+                }
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         $basedir = $dir;
</span></span></pre></div>
<a id="trunkwpincludesmsdefaultconstantsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-default-constants.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-default-constants.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-includes/ms-default-constants.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -10,11 +10,17 @@
</span><span class="cx"> /**
</span><span class="cx"> * Defines Multisite upload constants.
</span><span class="cx"> *
</span><ins>+ * Exists for backward compatibility with legacy file-serving through
+ * wp-includes/ms-files.php (wp-content/blogs.php in MU).
+ *
</ins><span class="cx"> * @since 3.0.0
</span><span class="cx"> */
</span><del>-function ms_upload_constants( ) {
</del><ins>+function ms_upload_constants() {
</ins><span class="cx">         global $wpdb;
</span><span class="cx">
</span><ins>+        if ( ! get_site_option( 'ms_files_rewriting' ) )
+                return;
+
</ins><span class="cx">         /** @since 3.0.0 */
</span><span class="cx">         // Base uploads dir relative to ABSPATH
</span><span class="cx">         if ( !defined( 'UPLOADBLOGSDIR' ) )
</span><span class="lines">@@ -24,7 +30,7 @@
</span><span class="cx">         if ( !defined( 'UPLOADS' ) ) {
</span><span class="cx">                 // Uploads dir relative to ABSPATH
</span><span class="cx">                 define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
</span><del>-                if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR )
</del><ins>+                if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) )
</ins><span class="cx">                         define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -74,9 +80,12 @@
</span><span class="cx"> /**
</span><span class="cx"> * Defines Multisite file constants.
</span><span class="cx"> *
</span><ins>+ * Exists for backward compatibility with legacy file-serving through
+ * wp-includes/ms-files.php (wp-content/blogs.php in MU).
+ *
</ins><span class="cx"> * @since 3.0.0
</span><span class="cx"> */
</span><del>-function ms_file_constants( ) {
</del><ins>+function ms_file_constants() {
</ins><span class="cx">         /**
</span><span class="cx">          * Optional support for X-Sendfile header
</span><span class="cx">          * @since 3.0.0
</span></span></pre></div>
<a id="trunkwpincludesmsdefaultfiltersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-default-filters.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-default-filters.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-includes/ms-default-filters.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -61,3 +61,6 @@
</span><span class="cx"> // WP_HOME and WP_SITEURL should not have any effect in MS
</span><span class="cx"> remove_filter( 'option_siteurl', '_config_wp_siteurl' );
</span><span class="cx"> remove_filter( 'option_home', '_config_wp_home' );
</span><ins>+
+// If the network upgrade hasn't run yet, assume ms-files.php rewriting is used.
+add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesmsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-functions.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-functions.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-includes/ms-functions.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -1120,8 +1120,7 @@
</span><span class="cx"> * @param string $blog_title The title of the new site.
</span><span class="cx"> */
</span><span class="cx"> function install_blog($blog_id, $blog_title = '') {
</span><del>-        global $wpdb, $table_prefix, $wp_roles;
-        $wpdb->suppress_errors();
</del><ins>+        global $wpdb, $wp_roles, $current_site;
</ins><span class="cx">
</span><span class="cx">         // Cast for security
</span><span class="cx">         $blog_id = (int) $blog_id;
</span><span class="lines">@@ -1129,12 +1128,10 @@
</span><span class="cx">         require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
</span><span class="cx">
</span><span class="cx">         if ( $wpdb->get_results("SELECT ID FROM $wpdb->posts") )
</span><del>-                die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
</del><ins>+                die( __( '<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>' ) . '</body></html>' );
</ins><span class="cx">
</span><del>-        $wpdb->suppress_errors(false);
</del><ins>+        $url = get_blogaddress_by_id( $blog_id );
</ins><span class="cx">
</span><del>-        $url = get_blogaddress_by_id($blog_id);
-
</del><span class="cx">         // Set everything up
</span><span class="cx">         make_db_current_silent( 'blog' );
</span><span class="cx">         populate_options();
</span><span class="lines">@@ -1142,21 +1139,22 @@
</span><span class="cx">         $wp_roles->_init();
</span><span class="cx">
</span><span class="cx">         $url = untrailingslashit( $url );
</span><del>-        // fix url.
-        update_option('siteurl', $url);
-        update_option('home', $url);
-        update_option('fileupload_url', $url . "/files" );
-        update_option('upload_path', UPLOADBLOGSDIR . "/$blog_id/files");
-        update_option('blogname', stripslashes( $blog_title ) );
-        update_option('admin_email', '');
-        $wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') );
</del><span class="cx">
</span><del>-        // remove all perms
-        $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'user_level' ) );
</del><ins>+        update_option( 'siteurl', $url );
+        update_option( 'home', $url );
</ins><span class="cx">
</span><del>-        $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'capabilities' ) );
</del><ins>+        if ( get_site_option( 'ms_files_rewriting' ) )
+                update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
+        else
+                update_option( 'upload_path', get_blog_option( $current_site->blog_id, 'upload_path' ) );
</ins><span class="cx">
</span><del>-        $wpdb->suppress_errors( false );
</del><ins>+        update_option( 'blogname', stripslashes( $blog_title ) );
+        update_option( 'admin_email', '' );
+
+        // remove all perms
+        $table_prefix = $wpdb->get_blog_prefix();
+        delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all
+        delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpincludesoptionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/option.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/option.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-includes/option.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -174,7 +174,7 @@
</span><span class="cx">         if ( empty($site_id) )
</span><span class="cx">                 $site_id = $wpdb->siteid;
</span><span class="cx">
</span><del>-        $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled' );
</del><ins>+        $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
</ins><span class="cx">
</span><span class="cx">         $core_options_in = "'" . implode("', '", $core_options) . "'";
</span><span class="cx">         $options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
</span></span></pre></div>
<a id="trunkwpincludesrewritephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/rewrite.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/rewrite.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-includes/rewrite.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -1742,15 +1742,19 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         if (is_subdomain_install()) {
</span><span class="cx">                                 $rules .= '
</span><del>-                                <rule name="wordpress - Rule 1" stopProcessing="true">
</del><ins>+                                <rule name="WordPress Rule 1" stopProcessing="true">
</ins><span class="cx">                                         <match url="^index\.php$" ignoreCase="false" />
</span><span class="cx">                                         <action type="None" />
</span><del>-                                </rule>
-                                <rule name="wordpress - Rule 2" stopProcessing="true">
</del><ins>+                                </rule>';
+                                if ( get_site_option( 'ms_files_rewriting' ) ) {
+                                        $rules .= '
+                                <rule name="WordPress Rule for Files" stopProcessing="true">
</ins><span class="cx">                                         <match url="^files/(.+)" ignoreCase="false" />
</span><span class="cx">                                         <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
</span><del>-                                </rule>
-                                <rule name="wordpress - Rule 3" stopProcessing="true">
</del><ins>+                                </rule>';
+                                }
+                                $rules .= '
+                                <rule name="WordPress Rule 2" stopProcessing="true">
</ins><span class="cx">                                         <match url="^" ignoreCase="false" />
</span><span class="cx">                                         <conditions logicalGrouping="MatchAny">
</span><span class="cx">                                                 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
</span><span class="lines">@@ -1758,25 +1762,29 @@
</span><span class="cx">                                         </conditions>
</span><span class="cx">                                         <action type="None" />
</span><span class="cx">                                 </rule>
</span><del>-                                <rule name="wordpress - Rule 4" stopProcessing="true">
</del><ins>+                                <rule name="WordPress Rule 3" stopProcessing="true">
</ins><span class="cx">                                         <match url="." ignoreCase="false" />
</span><span class="cx">                                         <action type="Rewrite" url="index.php" />
</span><span class="cx">                                 </rule>';
</span><span class="cx">                         } else {
</span><span class="cx">                                 $rules .= '
</span><del>-                                <rule name="wordpress - Rule 1" stopProcessing="true">
</del><ins>+                                <rule name="WordPress Rule 1" stopProcessing="true">
</ins><span class="cx">                                         <match url="^index\.php$" ignoreCase="false" />
</span><span class="cx">                                         <action type="None" />
</span><del>-                                </rule>
-                                <rule name="wordpress - Rule 2" stopProcessing="true">
</del><ins>+                                </rule>';
+                                if ( get_site_option( 'ms_files_rewriting' ) ) {
+                                        $rules .= '
+                                <rule name="WordPress Rule for Files" stopProcessing="true">
</ins><span class="cx">                                         <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
</span><span class="cx">                                         <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
</span><del>-                                </rule>
-                                <rule name="wordpress - Rule 3" stopProcessing="true">
</del><ins>+                                </rule>';
+                                }
+                                $rules .= '
+                                <rule name="WordPress Rule 2" stopProcessing="true">
</ins><span class="cx">                                         <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
</span><span class="cx">                                         <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
</span><span class="cx">                                 </rule>
</span><del>-                                <rule name="wordpress - Rule 4" stopProcessing="true">
</del><ins>+                                <rule name="WordPress Rule 3" stopProcessing="true">
</ins><span class="cx">                                         <match url="^" ignoreCase="false" />
</span><span class="cx">                                         <conditions logicalGrouping="MatchAny">
</span><span class="cx">                                                 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
</span><span class="lines">@@ -1784,15 +1792,15 @@
</span><span class="cx">                                         </conditions>
</span><span class="cx">                                         <action type="None" />
</span><span class="cx">                                 </rule>
</span><del>-                                <rule name="wordpress - Rule 5" stopProcessing="true">
</del><ins>+                                <rule name="WordPress Rule 4" stopProcessing="true">
</ins><span class="cx">                                         <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
</span><span class="cx">                                         <action type="Rewrite" url="{R:1}" />
</span><span class="cx">                                 </rule>
</span><del>-                                <rule name="wordpress - Rule 6" stopProcessing="true">
</del><ins>+                                <rule name="WordPress Rule 5" stopProcessing="true">
</ins><span class="cx">                                         <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
</span><span class="cx">                                         <action type="Rewrite" url="{R:2}" />
</span><span class="cx">                                 </rule>
</span><del>-                                <rule name="wordpress - Rule 7" stopProcessing="true">
</del><ins>+                                <rule name="WordPress Rule 6" stopProcessing="true">
</ins><span class="cx">                                         <match url="." ignoreCase="false" />
</span><span class="cx">                                         <action type="Rewrite" url="index.php" />
</span><span class="cx">                                 </rule>';
</span></span></pre></div>
<a id="trunkwpincludesversionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/version.php (21822 => 21823)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/version.php        2012-09-11 22:06:49 UTC (rev 21822)
+++ trunk/wp-includes/version.php        2012-09-11 22:22:20 UTC (rev 21823)
</span><span class="lines">@@ -11,7 +11,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @global int $wp_db_version
</span><span class="cx"> */
</span><del>-$wp_db_version = 21818;
</del><ins>+$wp_db_version = 21823;
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Holds the TinyMCE version
</span></span></pre>
</div>
</div>
</body>
</html>