Make WordPress Core

Ticket #19235: 19235.diff

File 19235.diff, 13.8 KB (added by nacin, 12 years ago)

First pass rips out everything without regard for an upgrade path or any kind of back compat. Meant for basic testing/review of the approach.

  • wp-includes/functions.php

     
    14361436        $siteurl = get_option( 'siteurl' );
    14371437        $upload_path = get_option( 'upload_path' );
    14381438        $upload_path = trim($upload_path);
    1439         $main_override = is_multisite() && defined( 'MULTISITE' ) && is_main_site();
    14401439        if ( empty($upload_path) ) {
    14411440                $dir = WP_CONTENT_DIR . '/uploads';
    14421441        } else {
     
    14561455                        $url = trailingslashit( $siteurl ) . $upload_path;
    14571456        }
    14581457
    1459         if ( defined('UPLOADS') && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
     1458        if ( defined( 'UPLOADS' ) ) {
    14601459                $dir = ABSPATH . UPLOADS;
    14611460                $url = trailingslashit( $siteurl ) . UPLOADS;
    1462         }
    14631461
    1464         if ( is_multisite() && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
    1465                 if ( defined( 'BLOGUPLOADDIR' ) )
    1466                         $dir = untrailingslashit(BLOGUPLOADDIR);
    1467                 $url = str_replace( UPLOADS, 'files', $url );
     1462                // If multisite, we're not switched, and we're not on the main site (for post-MU networks), append sites/ID
     1463                if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) && empty( $switched ) ) {
     1464                        $dir .= '/sites/' . $blog_id;
     1465                        $url .= '/sites/' . $blog_id;
     1466                }
    14681467        }
    14691468
    14701469        $bdir = $dir;
  • wp-includes/ms-default-constants.php

     
    1212 *
    1313 * @since 3.0.0
    1414 */
    15 function ms_upload_constants(  ) {
    16         global $wpdb;
     15function ms_upload_constants() {}
    1716
    18         /** @since 3.0.0 */
    19         // Base uploads dir relative to ABSPATH
    20         if ( !defined( 'UPLOADBLOGSDIR' ) )
    21                 define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' );
    22 
    23         /** @since 3.0.0 */
    24         if ( !defined( 'UPLOADS' ) ) {
    25                 // Uploads dir relative to ABSPATH
    26                 define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
    27                 if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR )
    28                         define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
    29         }
    30 }
    31 
    3217/**
    3318 * Defines Multisite cookie constants.
    3419 *
  • wp-includes/ms-functions.php

     
    11541154        // fix url.
    11551155        update_option('siteurl', $url);
    11561156        update_option('home', $url);
    1157         update_option('fileupload_url', $url . "/files" );
    1158         update_option('upload_path', UPLOADBLOGSDIR . "/$blog_id/files");
     1157
     1158        update_option('upload_path', "wp-content/uploads/sites/$blog_id"); // Don't know how this should be calculated.
    11591159        update_option('blogname', stripslashes( $blog_title ) );
    11601160        update_option('admin_email', '');
    11611161        $wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') );
  • wp-admin/network.php

     
    1515/** WordPress Administration Bootstrap */
    1616require_once( './admin.php' );
    1717
     18function ms_files_rewriting_enabled() { return false; }
     19
    1820if ( ! is_super_admin() )
    1921        wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
    2022
     
    106108$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>' .
    107109        '<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>' .
    108110        '<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>' .
    109         '<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>' .
     111        '<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>' .
    110112        '<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>' .
    111113        '<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>' .
    112114        '<p><strong>' . __('For more information:') . '</strong></p>' .
     
    360362        }
    361363?>
    362364                <ol>
    363                         <li><p><?php
    364                                 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 );
    365                                 if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
    366                                         echo ' <strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong>';
    367                         ?></p></li>
     365                        <?php
     366                        if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
     367                                echo '<li><p><strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p></li>';
     368                        ?>
    368369                        <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>
    369370                                <textarea class="code" readonly="readonly" cols="100" rows="7">
    370371define('MULTISITE', true);
     
    415416                <rule name="WordPress Rule 1" stopProcessing="true">
    416417                    <match url="^index\.php$" ignoreCase="false" />
    417418                    <action type="None" />
    418                 </rule>
    419                 <rule name="WordPress Rule 2" stopProcessing="true">
     419                </rule>';
     420                                if ( ms_files_rewriting_enabled() ) {
     421                                        $web_config_file .= '
     422                <rule name="WordPress Rule for Files" stopProcessing="true">
    420423                    <match url="^files/(.+)" ignoreCase="false" />
    421424                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
    422                 </rule>
    423                 <rule name="WordPress Rule 3" stopProcessing="true">
     425                </rule>';
     426                }
     427                $web_config_file .= '
     428                <rule name="WordPress Rule 2" stopProcessing="true">
    424429                    <match url="^" ignoreCase="false" />
    425430                    <conditions logicalGrouping="MatchAny">
    426431                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
     
    428433                    </conditions>
    429434                    <action type="None" />
    430435                </rule>
    431                 <rule name="WordPress Rule 4" stopProcessing="true">
     436                <rule name="WordPress Rule 3" stopProcessing="true">
    432437                    <match url="." ignoreCase="false" />
    433438                    <action type="Rewrite" url="index.php" />
    434439                </rule>
     
    446451                <rule name="WordPress Rule 1" stopProcessing="true">
    447452                    <match url="^index\.php$" ignoreCase="false" />
    448453                    <action type="None" />
    449                 </rule>
     454                </rule>';
     455                                if ( ms_files_rewriting_enabled() ) {
     456                                        $web_config_file .= '
     457                <rule name="WordPress Rule for Files" stopProcessing="true">
     458                    <match url="^files/(.+)" ignoreCase="false" />
     459                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
     460                </rule>';
     461                }
     462                $web_config_file .= '
    450463                <rule name="WordPress Rule 2" stopProcessing="true">
    451                     <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
    452                     <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
    453                 </rule>
    454                 <rule name="WordPress Rule 3" stopProcessing="true">
    455464                    <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
    456465                    <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
    457466                </rule>
    458                 <rule name="WordPress Rule 4" stopProcessing="true">
     467                <rule name="WordPress Rule 3" stopProcessing="true">
    459468                    <match url="^" ignoreCase="false" />
    460469                    <conditions logicalGrouping="MatchAny">
    461470                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
     
    463472                    </conditions>
    464473                    <action type="None" />
    465474                </rule>
    466                 <rule name="WordPress Rule 5" stopProcessing="true">
     475                <rule name="WordPress Rule 4" stopProcessing="true">
    467476                    <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
    468477                    <action type="Rewrite" url="{R:1}" />
    469478                </rule>
    470                 <rule name="WordPress Rule 6" stopProcessing="true">
     479                <rule name="WordPress Rule 5" stopProcessing="true">
    471480                    <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
    472481                    <action type="Rewrite" url="{R:2}" />
    473482                </rule>
    474                 <rule name="WordPress Rule 7" stopProcessing="true">
     483                <rule name="WordPress Rule 6" stopProcessing="true">
    475484                    <match url="." ignoreCase="false" />
    476485                    <action type="Rewrite" url="index.php" />
    477486                </rule>
     
    491500
    492501                $htaccess_file = 'RewriteEngine On
    493502RewriteBase ' . $base . '
    494 RewriteRule ^index\.php$ - [L]
     503RewriteRule ^index\.php$ - [L]' . "\n";
    495504
    496 # uploaded files
    497 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
     505                if ( ms_files_rewriting_enabled() ) {
     506                        $htaccess_file .= "\n\n# uploaded files\nRewriteRule ^";
     507                        $htaccess_file .= ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
     508                }
    498509
    499510                if ( ! $subdomain_install )
    500511                        $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
     
    511522
    512523                ?>
    513524                <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
    514                 <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">
     525                <textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
    515526<?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
    516527                </ol>
    517528
  • wp-admin/includes/schema.php

     
    932932                        $upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
    933933                        update_option( 'upload_path', $upload_path );
    934934                }
    935                 update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );
    936935        }
    937936
    938937        if ( $subdomain_install )
  • wp-admin/includes/ms.php

     
    9090
    9191                $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
    9292
    93                 $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );
     93                $uploads = wp_upload_dir();
     94                $dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
    9495                $dir = rtrim( $dir, DIRECTORY_SEPARATOR );
    9596                $top_dir = $dir;
    9697                $stack = array($dir);
     
    347348function get_space_used() {
    348349        // Allow for an alternative way of tracking storage space used
    349350        $space_used = apply_filters( 'pre_get_space_used', false );
    350         if ( false === $space_used )
    351                 $space_used = get_dirsize( BLOGUPLOADDIR );
     351        if ( false === $space_used ) {
     352                $upload_dir = wp_upload_dir();
     353                $space_used = get_dirsize( $upload_dir['basedir'] );
     354        }
    352355
    353356        return $space_used;
    354357}
     
    665668        <?php
    666669}
    667670
    668 function ms_deprecated_blogs_file() {
    669         if ( ! is_super_admin() )
    670                 return;
    671         if ( ! file_exists( WP_CONTENT_DIR . '/blogs.php' ) )
    672                 return;
    673         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>';
    674 }
    675 add_action( 'network_admin_notices', 'ms_deprecated_blogs_file' );
    676 
    677671/**
    678672 * Grants super admin privileges.
    679673 *