Ticket #2524: table_prefix.diff
| File table_prefix.diff, 8.0 KB (added by markjaquith, 6 years ago) |
|---|
-
wp-includes/capabilities.php
8 8 var $role_key; 9 9 10 10 function WP_Roles() { 11 global $ table_prefix;12 $this->role_key = $ table_prefix . 'user_roles';11 global $wpdb; 12 $this->role_key = $wpdb->table_prefix . 'user_roles'; 13 13 14 14 $this->roles = get_option($this->role_key); 15 15 … … 121 121 var $allcaps = array(); 122 122 123 123 function WP_User($id, $name = '') { 124 global $ table_prefix;124 global $wpdb; 125 125 126 126 if ( empty($id) && empty($name) ) 127 127 return; … … 144 144 } 145 145 146 146 $this->id = $this->ID; 147 $this->cap_key = $ table_prefix . 'capabilities';147 $this->cap_key = $wpdb->table_prefix . 'capabilities'; 148 148 $this->caps = &$this->{$this->cap_key}; 149 149 if ( ! is_array($this->caps) ) 150 150 $this->caps = array(); … … 205 205 } 206 206 207 207 function update_user_level_from_caps() { 208 global $ table_prefix;208 global $wpdb; 209 209 $this->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0); 210 update_usermeta($this->id, $ table_prefix.'user_level', $this->user_level);210 update_usermeta($this->id, $wpdb->table_prefix.'user_level', $this->user_level); 211 211 } 212 212 213 213 function add_cap($cap, $grant = true) { -
wp-content/plugins/wp-db-backup.php
103 103 } 104 104 105 105 function build_backup_script() { 106 global $ table_prefix, $wpdb;106 global $wpdb; 107 107 108 108 $datum = date("Ymd_B"); 109 $backup_filename = DB_NAME . "_$table_prefix$datum.sql";109 $backup_filename = DB_NAME . '_' . $wpdb->table_prefix . $datum . '.sql'; 110 110 if ($this->gzip()) $backup_filename .= '.gz'; 111 111 112 112 echo "<div class='wrap'>"; … … 223 223 } 224 224 225 225 function backup_fragment($table, $segment, $filename) { 226 global $ table_prefix, $wpdb;226 global $wpdb; 227 227 228 228 echo "$table:$segment:$filename"; 229 229 … … 555 555 556 556 //////////////////////////// 557 557 function db_backup($core_tables, $other_tables) { 558 global $ table_prefix, $wpdb;558 global $wpdb; 559 559 560 560 $datum = date("Ymd_B"); 561 $wp_backup_filename = DB_NAME . "_$table_prefix$datum.sql";561 $wp_backup_filename = DB_NAME . '_' . $wpdb->table_prefix . $datum . '.sql'; 562 562 if ($this->gzip()) { 563 563 $wp_backup_filename .= '.gz'; 564 564 } … … 672 672 673 673 //////////////////////////// 674 674 function backup_menu() { 675 global $ table_prefix, $wpdb;675 global $wpdb; 676 676 $feedback = ''; 677 677 $WHOOPS = FALSE; 678 678 … … 720 720 // Simple table name storage 721 721 $wp_table_names = explode(',','categories,comments,linkcategories,links,options,post2cat,postmeta,posts,users,usermeta'); 722 722 // Apply WP DB prefix to table names 723 $wp_table_names = array_map(create_function('$a', 'global $ table_prefix;return "{$table_prefix}{$a}";'), $wp_table_names);723 $wp_table_names = array_map(create_function('$a', 'global $wpdb;return "{$wpdb->table_prefix}{$a}";'), $wp_table_names); 724 724 725 725 $other_tables = array(); 726 726 $also_backup = array(); … … 864 864 return; 865 865 } 866 866 867 global $ table_prefix, $wpdb;867 global $wpdb; 868 868 869 869 $wp_table_names = explode(',','categories,comments,linkcategories,links,options,post2cat,postmeta,posts,users,usermeta'); 870 $wp_table_names = array_map(create_function('$a', 'global $ table_prefix;return "{$table_prefix}{$a}";'), $wp_table_names);870 $wp_table_names = array_map(create_function('$a', 'global $wpdb;return "{$wpdb->table_prefix}{$a}";'), $wp_table_names); 871 871 $all_tables = $wpdb->get_results("SHOW TABLES", ARRAY_N); 872 872 $all_tables = array_map(create_function('$a', 'return $a[0];'), $all_tables); 873 873 $core_tables = array_intersect($all_tables, $wp_table_names); -
wp-admin/upgrade-functions.php
167 167 } 168 168 169 169 function upgrade_130() { 170 global $wpdb , $table_prefix;170 global $wpdb; 171 171 172 172 // Remove extraneous backslashes. 173 173 $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts"); … … 220 220 } 221 221 222 222 // Obsolete tables 223 $wpdb->query('DROP TABLE IF EXISTS ' . $ table_prefix . 'optionvalues');224 $wpdb->query('DROP TABLE IF EXISTS ' . $ table_prefix . 'optiontypes');225 $wpdb->query('DROP TABLE IF EXISTS ' . $ table_prefix . 'optiongroups');226 $wpdb->query('DROP TABLE IF EXISTS ' . $ table_prefix . 'optiongroup_options');223 $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->table_prefix . 'optionvalues'); 224 $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->table_prefix . 'optiontypes'); 225 $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->table_prefix . 'optiongroups'); 226 $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->table_prefix . 'optiongroup_options'); 227 227 228 228 // Update comments table to use comment_type 229 229 $wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'"); … … 244 244 } 245 245 246 246 function upgrade_160() { 247 global $wpdb, $ table_prefix, $wp_current_db_version;247 global $wpdb, $wp_current_db_version; 248 248 249 249 populate_roles_160(); 250 250 … … 257 257 if ( !empty( $user->user_nickname ) ) 258 258 update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) ); 259 259 if ( !empty( $user->user_level ) ) 260 update_usermeta( $user->ID, $ table_prefix . 'user_level', $user->user_level );260 update_usermeta( $user->ID, $wpdb->table_prefix . 'user_level', $user->user_level ); 261 261 if ( !empty( $user->user_icq ) ) 262 262 update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) ); 263 263 if ( !empty( $user->user_aim ) ) … … 283 283 endif; 284 284 285 285 // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set. 286 $caps = get_usermeta( $user->ID, $ table_prefix . 'capabilities');286 $caps = get_usermeta( $user->ID, $wpdb->table_prefix . 'capabilities'); 287 287 if ( empty($caps) || defined('RESET_CAPS') ) { 288 $level = get_usermeta($user->ID, $ table_prefix . 'user_level');288 $level = get_usermeta($user->ID, $wpdb->table_prefix . 'user_level'); 289 289 $role = translate_level_to_role($level); 290 update_usermeta( $user->ID, $ table_prefix . 'capabilities', array($role => true) );290 update_usermeta( $user->ID, $wpdb->table_prefix . 'capabilities', array($role => true) ); 291 291 } 292 292 293 293 endforeach; … … 331 331 } 332 332 333 333 function upgrade_210() { 334 global $wpdb, $ table_prefix, $wp_current_db_version;334 global $wpdb, $wp_current_db_version; 335 335 336 336 if ( $wp_current_db_version < 3506 ) { 337 337 // Update status and type. -
wp-admin/install.php
202 202 $display_name_array = explode('@', $admin_email); 203 203 $display_name = $display_name_array[0]; 204 204 $wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_registered, display_name, user_nicename) VALUES ( '1', 'admin', MD5('$random_password'), '$admin_email', NOW(), '$display_name', 'admin')"); 205 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{ $table_prefix}user_level', '10');");205 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{prefix}user_level', '10');"); 206 206 $admin_caps = serialize(array('administrator' => true)); 207 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{ $table_prefix}capabilities', '{$admin_caps}');");207 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{prefix}capabilities', '{$admin_caps}');"); 208 208 209 209 $message_headers = 'From: ' . $weblog_title . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>'; 210 210 $message = sprintf(__("Your new WordPress blog has been successfully set up at:
