Make WordPress Core

Changeset 12753


Ignore:
Timestamp:
01/18/2010 10:21:36 PM (14 years ago)
Author:
ryan
Message:

Use cap checks instead of multisite and super admin checks. Add some new caps. Merge cleanup. see #11644.

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin.php

    r12736 r12753  
    199199
    200200    define('WP_IMPORTING', true);
    201     if ( is_multisite() ) {
     201
     202    if ( is_multisite() )
    202203        kses_init_filters();  // Always filter imported data with kses.
    203     }
    204204
    205205    call_user_func($wp_importers[$importer][2]);
  • trunk/wp-admin/includes/schema.php

    r12733 r12753  
    370370    populate_roles_270();
    371371    populate_roles_280();
     372    populate_roles_300();
    372373}
    373374
     
    591592}
    592593
     594/**
     595 * Create and modify WordPress roles for WordPress 2.8.
     596 *
     597 * @since 2.8.0
     598 */
     599function populate_roles_300() {
     600    $role =& get_role( 'administrator' );
     601
     602    if ( !empty( $role ) ) {
     603        $role->add_cap( 'update_core' );
     604        $role->add_cap( 'remove_user' );
     605        $role->add_cap( 'remove_users' );
     606    }
     607}
     608
    593609?>
  • trunk/wp-admin/includes/update.php

    r12752 r12753  
    8383
    8484function core_update_footer( $msg = '' ) {
    85     if ( is_multisite() && !is_super_admin() )
    86         return false;
    87 
    88     if ( !current_user_can('manage_options') )
     85    if ( is_multisite() && !current_user_can('update_core') )
     86        return false;
     87
     88    if ( !current_user_can('update_core') )
    8989        return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] );
    9090
     
    105105
    106106    case 'upgrade' :
    107         if ( current_user_can('manage_options') ) {
    108             return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', 'update-core.php', $cur->current);
    109             break;
    110         }
     107        return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', 'update-core.php', $cur->current);
     108    break;
    111109
    112110    case 'latest' :
     
    119117
    120118function update_nag() {
    121     if ( is_multisite() && !is_super_admin() )
     119    if ( is_multisite() && !current_user_can('update_core') )
    122120        return false;
    123121
     
    132130        return false;
    133131
    134     if ( current_user_can('manage_options') )
     132    if ( current_user_can('update_core') )
    135133        $msg = sprintf( __('WordPress %1$s is available! <a href="%2$s">Please update now</a>.'), $cur->current, 'update-core.php' );
    136134    else
     
    143141// Called directly from dashboard
    144142function update_right_now_message() {
    145     if ( is_multisite() && !is_super_admin() )
     143    if ( is_multisite() && !current_user_can('update_core') )
    146144        return false;
    147145
     
    149147
    150148    $msg = sprintf( __('You are using <span class="b">WordPress %s</span>.'), $GLOBALS['wp_version'] );
    151     if ( isset( $cur->response ) && $cur->response == 'upgrade' && current_user_can('manage_options') )
     149    if ( isset( $cur->response ) && $cur->response == 'upgrade' && current_user_can('update_core') )
    152150        $msg .= " <a href='update-core.php' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
    153151
     
    170168
    171169function wp_plugin_update_rows() {
     170    if ( !current_user_can('update_plugins' ) )
     171        return;
     172
    172173    $plugins = get_site_transient( 'update_plugins' );
    173174    if ( isset($plugins->response) && is_array($plugins->response) ) {
     
    206207
    207208function wp_update_plugin($plugin, $feedback = '') {
    208     if ( is_multisite() && !is_super_admin() )
    209         return false;
    210 
    211 
    212209    if ( !empty($feedback) )
    213210        add_filter('update_feedback', $feedback);
     
    235232
    236233function wp_update_theme($theme, $feedback = '') {
    237 
    238234    if ( !empty($feedback) )
    239235        add_filter('update_feedback', $feedback);
     
    246242
    247243function wp_update_core($current, $feedback = '') {
    248 
    249244    if ( !empty($feedback) )
    250245        add_filter('update_feedback', $feedback);
     
    261256        return false;
    262257
    263     if ( current_user_can('manage_options') )
     258    if ( current_user_can('update_core') )
    264259        $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' );
    265260    else
  • trunk/wp-admin/includes/upgrade.php

    r12752 r12753  
    260260 */
    261261function wp_upgrade() {
    262     global $wp_current_db_version, $wp_db_version;
     262    global $wp_current_db_version, $wp_db_version, $wpdb;
    263263
    264264    $wp_current_db_version = __get_option('db_version');
     
    277277    upgrade_all();
    278278    wp_cache_flush();
     279
     280    if ( is_multisite() ) {
     281        if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) {
     282            $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
     283        } else {
     284            $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
     285        }
     286    }
    279287}
    280288endif;
     
    352360    if ( $wp_current_db_version < 11958 )
    353361        upgrade_290();
     362
     363    if ( $wp_current_db_version < 12751 )
     364        upgrade_300();
    354365
    355366    maybe_disable_automattic_widgets();
     
    10071018}
    10081019
     1020/**
     1021 * Execute changes made in WordPress 3.0.
     1022 *
     1023 * @since 3.0
     1024 */
     1025function upgrade_300() {
     1026    populate_roles_300();
     1027}
    10091028
    10101029// The functions we use to actually do stuff
  • trunk/wp-admin/menu.php

    r12738 r12753  
    3131    $menu[1] = array( '', 'read', 'separator0', '', 'wp-menu-separator' );
    3232    $menu[2] = array(__('Site Admin'), '10', 'ms-admin.php', '', 'menu-top menu-top-first', 'menu-site', 'div');
    33     $submenu[ 'ms-admin.php' ][1] = array( __('Admin'), 'delete_users', 'ms-admin.php' );
    34     $submenu[ 'ms-admin.php' ][5] = array( __('Blogs'), 'delete_users', 'ms-sites.php' );
    35     $submenu[ 'ms-admin.php' ][10] = array( __('Users'), 'delete_users', 'ms-users.php' );
    36     $submenu[ 'ms-admin.php' ][20] = array( __('Themes'), 'delete_users', 'ms-themes.php' );
    37     $submenu[ 'ms-admin.php' ][25] = array( __('Options'), 'delete_users', 'ms-options.php' );
    38     $submenu[ 'ms-admin.php' ][30] = array( __('Upgrade'), 'delete_users', 'ms-upgrade-site.php' );
     33    $submenu[ 'ms-admin.php' ][1] = array( __('Admin'), 'super_admin', 'ms-admin.php' );
     34    $submenu[ 'ms-admin.php' ][5] = array( __('Blogs'), 'super_admin', 'ms-sites.php' );
     35    $submenu[ 'ms-admin.php' ][10] = array( __('Users'), 'super_admin', 'ms-users.php' );
     36    $submenu[ 'ms-admin.php' ][20] = array( __('Themes'), 'super_admin', 'ms-themes.php' );
     37    $submenu[ 'ms-admin.php' ][25] = array( __('Options'), 'super_admin', 'ms-options.php' );
     38    $submenu[ 'ms-admin.php' ][30] = array( __('Upgrade'), 'super_admin', 'ms-upgrade-site.php' );
    3939}
    4040
     
    106106    if ( !is_multisite() )
    107107        $submenu['themes.php'][10] = array(__('Editor'), 'edit_themes', 'theme-editor.php');
    108     if ( is_super_admin() )
    109         $submenu['themes.php'][15] = array(__('Add New Themes'), 'install_themes', 'theme-install.php');
     108    $submenu['themes.php'][15] = array(__('Add New Themes'), 'install_themes', 'theme-install.php');
    110109
    111110$update_plugins = get_site_transient( 'update_plugins' );
     
    118117    $menu[65] = array( sprintf( __('Plugins %s'), "<span class='update-plugins count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'activate_plugins', 'plugins.php', '', 'menu-top', 'menu-plugins', 'div' );
    119118        $submenu['plugins.php'][5]  = array( __('Installed'), 'activate_plugins', 'plugins.php' );
    120         if ( is_super_admin() ) {
    121             /* translators: add new plugin */
    122             $submenu['plugins.php'][10] = array(_x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php');
    123         }
     119        /* translators: add new plugin */
     120        $submenu['plugins.php'][10] = array(_x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php');
    124121        if ( !is_multisite() )
    125122            $submenu['plugins.php'][15] = array( __('Editor'), 'edit_plugins', 'plugin-editor.php' );
  • trunk/wp-admin/options-general.php

    r12752 r12753  
    293293<?php do_settings_fields('general', 'default'); ?>
    294294<?php
    295 if ( is_multisite() && is_dir( ABSPATH . LANGDIR ) && $dh = opendir( ABSPATH . LANGDIR ) )
    296     while( ( $lang_file = readdir( $dh ) ) !== false )
     295
     296$lang_files = array();
     297if ( is_multisite() && is_dir( ABSPATH . LANGDIR ) && $dh = opendir( ABSPATH . LANGDIR ) ) {
     298    while ( ( $lang_file = readdir( $dh ) ) !== false ) {
    297299        if ( substr( $lang_file, -3 ) == '.mo' )
    298300            $lang_files[] = $lang_file;
    299 $lang = get_option('WPLANG');
    300 
    301 if ( is_array($lang_files) && !empty($lang_files) ) {
    302     ?>
     301    }
     302}
     303
     304if ( !empty($lang_files) ) {
     305?>
    303306    <tr valign="top">
    304307        <th width="33%" scope="row"><?php _e('Blog language:') ?></th>
     
    309312        </td>
    310313    </tr>
    311     <?php
     314<?php
    312315} // languages
    313316?>
  • trunk/wp-admin/options.php

    r12752 r12753  
    119119  <input type="hidden" name="action" value="update" />
    120120  <input type='hidden' name='option_page' value='options' />
    121 <?php if ( is_multisite() ) { ?>
    122 <p class="submit submit-top">
    123     <input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" class="button-primary" />
    124 </p>
    125 <?php } ?>
    126121  <table class="form-table">
    127122<?php
  • trunk/wp-admin/plugins.php

    r12752 r12753  
    232232
    233233$help = '<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>';
    234 if ( !is_multisite() || is_super_admin() ) {
     234if ( current_user_can('edit_plugins') ) {
    235235$help .= '<p>' . sprintf(__('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), WP_PLUGIN_DIR) . '</p>';
    236236$help .= '<p>' . sprintf(__('You can find additional plugins for your site by using the new <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> directly and installing manually.  To <em>manually</em> install a plugin you generally just need to upload the plugin file into your <code>%2$s</code> directory.  Once a plugin has been installed, you may activate it here.'), 'plugin-install.php', WP_PLUGIN_DIR) . '</p>';
     
    285285<div class="wrap">
    286286<?php screen_icon(); ?>
    287 <h2><?php echo esc_html( $title ); if ( !is_multisite() || is_super_admin() ) { ?> <a href="plugin-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a><?php } ?></h2>
     287<h2><?php echo esc_html( $title ); if ( current_user_can('install_plugins') ) { ?> <a href="plugin-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a><?php } ?></h2>
    288288
    289289<?php
     
    326326}
    327327
    328 if ( is_multisite() && !is_super_admin() ) {
    329     $upgrade_plugins = false;
    330 }
     328if ( !current_user_can('update_plugins') )
     329    $upgrade_plugins = array();
    331330
    332331$total_all_plugins = count($all_plugins);
  • trunk/wp-admin/themes.php

    r12752 r12753  
    6868
    6969require_once('admin-header.php');
    70 if ( is_multisite() && is_super_admin() ) {
     70if ( is_multisite() && current_user_can('edit_themes') ) {
    7171    ?><div id="message0" class="updated fade"><p><?php _e('Administrator: new themes must be activated in the <a href="wpmu-themes.php">Themes Admin</a> page before they appear here.'); ?></p></div><?php
    7272}
     
    127127    static $themes_update;
    128128
    129     if ( is_multisite() && !is_super_admin() )
     129    if ( !current_user_can('update_themes' ) )
    130130        return;
    131131
     
    160160<div class="wrap">
    161161<?php screen_icon(); ?>
    162 <h2><?php echo esc_html( $title ); if ( !is_multisite() || is_super_admin() ) { ?> <a href="theme-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php } ?></h2>
     162<h2><?php echo esc_html( $title ); if ( !current_user_can('install_themes') ) { ?> <a href="theme-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php } ?></h2>
    163163
    164164<h3><?php _e('Current Theme'); ?></h3>
     
    171171    printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h4>
    172172<p class="theme-description"><?php echo $ct->description; ?></p>
    173 <?php if ( ( !is_multisite() || is_super_admin() ) && $ct->parent_theme ) { ?>
     173<?php if ( current_user_can('edit_themes') && $ct->parent_theme ) { ?>
    174174    <p><?php printf(__('The template files are located in <code>%2$s</code>.  The stylesheet files are located in <code>%3$s</code>.  <strong>%4$s</strong> uses templates from <strong>%5$s</strong>.  Changes made to the templates will affect both themes.'), $ct->title, str_replace( WP_CONTENT_DIR, '', $ct->template_dir ), str_replace( WP_CONTENT_DIR, '', $ct->stylesheet_dir ), $ct->title, $ct->parent_theme); ?></p>
    175175<?php } else { ?>
     
    266266<p class="description"><?php echo $description; ?></p>
    267267<span class='action-links'><?php echo $actions ?></span>
    268     <?php if ( ( !is_multisite() || is_super_admin() ) && $parent_theme ) {
     268    <?php if ( current_user_can('edit_themes') && $parent_theme ) {
    269269    /* translators: 1: theme title, 2:  template dir, 3: stylesheet_dir, 4: theme title, 5: parent_theme */ ?>
    270270    <p><?php printf(__('The template files are located in <code>%2$s</code>.  The stylesheet files are located in <code>%3$s</code>.  <strong>%4$s</strong> uses templates from <strong>%5$s</strong>.  Changes made to the templates will affect both themes.'), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ), $title, $parent_theme); ?></p>
     
    299299// List broken themes, if any.
    300300$broken_themes = get_broken_themes();
    301 if ( ( !is_multisite() || is_super_admin() ) && count( $broken_themes ) ) {
     301if ( current_user_can('edit_themes') && count( $broken_themes ) ) {
    302302?>
    303303
  • trunk/wp-admin/upgrade.php

    r12752 r12753  
    8686            $backto = esc_url_raw( $backto );
    8787            $backto = wp_validate_redirect($backto, __get_option( 'home' ) . '/');
    88         if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) {
    89             $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
    90         } else {
    91             $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
    92         }
    9388?>
    9489<h2><?php _e( 'Upgrade Complete' ); ?></h2>
  • trunk/wp-admin/users.php

    r12752 r12753  
    1515if ( !current_user_can('edit_users') )
    1616    wp_die(__('Cheatin&#8217; uh?'));
     17
     18$del_cap_type = 'remove';
     19if ( !is_multisite() && current_user_can('delete_users') )
     20    $del_cap_type = 'delete';
    1721
    1822$title = __('Users');
     
    4448    check_admin_referer('bulk-users');
    4549
    46     if (empty($_REQUEST['users'])) {
     50    if ( empty($_REQUEST['users']) ) {
    4751        wp_redirect($redirect);
    4852        exit();
     
    5054
    5155    $editable_roles = get_editable_roles();
    52     if (!$editable_roles[$_REQUEST['new_role']])
     56    if ( !$editable_roles[$_REQUEST['new_role']] )
    5357        wp_die(__('You can&#8217;t give users that role.'));
    5458
    5559    $userids = $_REQUEST['users'];
    5660    $update = 'promote';
    57     foreach($userids as $id) {
     61    foreach ( $userids as $id ) {
    5862        if ( ! current_user_can('edit_user', $id) )
    5963            wp_die(__('You can&#8217;t edit that user.'));
    6064        // The new role of the current user must also have edit_users caps
    61         if($id == $current_user->ID && !$wp_roles->role_objects[$_REQUEST['new_role']]->has_cap('edit_users')) {
     65        if ( $id == $current_user->ID && !$wp_roles->role_objects[$_REQUEST['new_role']]->has_cap('edit_users') ) {
    6266            $update = 'err_admin_role';
    6367            continue;
     
    8286    }
    8387
    84     if ( !current_user_can('delete_users') )
     88    if ( !current_user_can($del_cap_type . '_users') )
    8589        wp_die(__('You can&#8217;t delete users.'));
    8690
     
    9094
    9195    foreach ( (array) $userids as $id) {
    92         if ( ! current_user_can('delete_user', $id) )
     96        if ( ! current_user_can($del_cap_type . '_user', $id) )
    9397            wp_die(__('You can&#8217;t delete that user.'));
    9498
    95         if ($id == $current_user->ID) {
     99        if ( $id == $current_user->ID ) {
    96100            $update = 'err_admin_del';
    97101            continue;
    98102        }
    99         switch($_REQUEST['delete_option']) {
     103        switch ( $_REQUEST['delete_option'] ) {
    100104        case 'delete':
    101             if ( !is_multisite() ) {
     105            if ( !is_multisite() && current_user_can('delete_user', $id) )
    102106                wp_delete_user($id);
    103             } else {
     107            else
    104108                remove_user_from_blog($id, $blog_id); // WPMU only remove user from blog
    105             }
    106109            break;
    107110        case 'reassign':
    108             if ( !is_multisite() ) {
     111            if ( !is_multisite() && current_user_can('delete_user', $id) )
    109112                wp_delete_user($id, $_REQUEST['reassign_user']);
    110             } else {
     113            else
    111114                remove_user_from_blog($id, $blog_id, $_REQUEST['reassign_user']);
    112             }
    113115            break;
    114116        }
     
    131133    }
    132134
    133     if ( !current_user_can('delete_users') )
     135    if ( !current_user_can($del_cap_type . '_users') )
    134136        $errors = new WP_Error('edit_users', __('You can&#8217;t delete users.'));
    135137
  • trunk/wp-includes/capabilities.php

    r12733 r12753  
    717717            $cap = $this->translate_level_to_cap( $cap );
    718718        }
     719
     720        // Multisite super admin has all caps by definition.
     721        if ( is_multisite() && is_super_admin() )
     722            return true;
    719723
    720724        $args = array_slice( func_get_args(), 1 );
     
    963967    case 'install_themes':
    964968    case 'edit_themes':
     969    case 'update_core':
     970    case 'delete_user':
     971    case 'delete_users':
    965972        // If multisite these caps are allowed only for super admins.
    966973        if ( is_multisite() && !is_super_admin() )
  • trunk/wp-includes/post.php

    r12751 r12753  
    32523252            if ( 0 === strpos($file, $uploads['basedir']) ) //Check that the upload base exists in the file location
    32533253                $url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); //replace file location with url location
    3254             elseif ( !is_multisite() ) {
    3255                                 if ( false !== strpos($file, 'wp-content/uploads') )
    3256                                         $url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
    3257                                 else
    3258                                         $url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir.
    3259                         }
     3254            elseif ( false !== strpos($file, 'wp-content/uploads') )
     3255                $url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
     3256            else
     3257                $url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir.
    32603258        }
    32613259    }
  • trunk/wp-includes/version.php

    r12456 r12753  
    1616 * @global int $wp_db_version
    1717 */
    18 $wp_db_version = 12329;
     18$wp_db_version = 12751;
    1919
    2020/**
  • trunk/wp-includes/wp-db.php

    r12733 r12753  
    371371            $this->show_errors();
    372372
    373                 if( is_multisite() ) {
    374                         $this->charset = 'utf8';
    375                         if( defined( 'DB_COLLATE' ) && constant( 'DB_COLLATE' ) != '' ) {
    376                                 $this->collate = constant( 'DB_COLLATE' );
    377                         } else {
    378                                 $this->collate = 'utf8_general_ci';
    379                         }
    380                 }
     373        if ( is_multisite() ) {
     374            $this->charset = 'utf8';
     375            if ( defined( 'DB_COLLATE' ) && constant( 'DB_COLLATE' ) != '' )
     376                $this->collate = constant( 'DB_COLLATE' );
     377            else
     378                $this->collate = 'utf8_general_ci';
     379        }
    381380
    382381        if ( defined('DB_CHARSET') )
     
    447446            return new WP_Error('invalid_db_prefix', /*WP_I18N_DB_BAD_PREFIX*/'Invalid database prefix'/*/WP_I18N_DB_BAD_PREFIX*/);
    448447
    449                 if( is_multisite() ) {
    450                         $old_prefix = '';
    451                 } else {
    452                         $old_prefix = $prefix;
    453                 }
    454         if( isset( $this->base_prefix ) )
     448        if ( is_multisite() )
     449            $old_prefix = '';
     450        else
     451            $old_prefix = $prefix;
     452
     453        if ( isset( $this->base_prefix ) )
    455454            $old_prefix = $this->base_prefix;
    456455        $this->base_prefix = $prefix;
     
    665664            return false;
    666665
    667                 // If there is an error then take note of it
    668                 if( is_multisite() ) {
    669                         $msg = "WordPress database error: [$str]\n{$this->last_query}\n";
    670                         if( defined( 'ERRORLOGFILE' ) )
    671                                 error_log( $msg, 3, CONSTANT( 'ERRORLOGFILE' ) );
    672                         if( defined( 'DIEONDBERROR' ) )
    673                                 die( $msg );
    674                 } else {
    675                         $str = htmlspecialchars($str, ENT_QUOTES);
    676                         $query = htmlspecialchars($this->last_query, ENT_QUOTES);
    677 
    678                         print "<div id='error'>
    679                         <p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
    680                         <code>$query</code></p>
    681                         </div>";
    682                 }
     666        // If there is an error then take note of it
     667        if ( is_multisite() ) {
     668            $msg = "WordPress database error: [$str]\n{$this->last_query}\n";
     669            if ( defined( 'ERRORLOGFILE' ) )
     670                error_log( $msg, 3, CONSTANT( 'ERRORLOGFILE' ) );
     671            if ( defined( 'DIEONDBERROR' ) )
     672                die( $msg );
     673        } else {
     674            $str = htmlspecialchars($str, ENT_QUOTES);
     675            $query = htmlspecialchars($this->last_query, ENT_QUOTES);
     676
     677            print "<div id='error'>
     678            <p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
     679            <code>$query</code></p>
     680            </div>";
     681        }
    683682    }
    684683
     
    740739    function db_connect( $query = "SELECT" ) {
    741740        global $db_list, $global_db_list;
    742         if( is_array( $db_list ) == false )
     741        if ( is_array( $db_list ) == false )
    743742            return true;
    744743
    745         if( $this->blogs != '' && preg_match("/(" . $this->blogs . "|" . $this->users . "|" . $this->usermeta . "|" . $this->site . "|" . $this->sitemeta . "|" . $this->sitecategories . ")/i",$query) ) {
     744        if ( $this->blogs != '' && preg_match("/(" . $this->blogs . "|" . $this->users . "|" . $this->usermeta . "|" . $this->site . "|" . $this->sitemeta . "|" . $this->sitecategories . ")/i",$query) ) {
    746745            $action = 'global';
    747746            $details = $global_db_list[ mt_rand( 0, count( $global_db_list ) -1 ) ];
Note: See TracChangeset for help on using the changeset viewer.