prefix not table_prefix. Props Kafkaesqui. fixes #2528

git-svn-id: http://svn.automattic.com/wordpress/trunk@3604 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-03-03 20:36:40 +00:00
parent df35b1041b
commit eaea1c6e70
4 changed files with 18 additions and 18 deletions

View File

@ -202,9 +202,9 @@ $random_password = substr(md5(uniqid(microtime())), 0, 6);
$display_name_array = explode('@', $admin_email);
$display_name = $display_name_array[0];
$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')");
$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$wpdb->table_prefix}user_level', '10');");
$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$wpdb->prefix}user_level', '10');");
$admin_caps = serialize(array('administrator' => true));
$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$wpdb->table_prefix}capabilities', '{$admin_caps}');");
$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$wpdb->prefix}capabilities', '{$admin_caps}');");
$message_headers = 'From: ' . $weblog_title . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
$message = sprintf(__("Your new WordPress blog has been successfully set up at:

View File

@ -220,10 +220,10 @@ function upgrade_130() {
}
// Obsolete tables
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->table_prefix . 'optionvalues');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->table_prefix . 'optiontypes');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->table_prefix . 'optiongroups');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->table_prefix . 'optiongroup_options');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
// Update comments table to use comment_type
$wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
@ -257,7 +257,7 @@ function upgrade_160() {
if ( !empty( $user->user_nickname ) )
update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
if ( !empty( $user->user_level ) )
update_usermeta( $user->ID, $wpdb->table_prefix . 'user_level', $user->user_level );
update_usermeta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
if ( !empty( $user->user_icq ) )
update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
if ( !empty( $user->user_aim ) )
@ -283,11 +283,11 @@ function upgrade_160() {
endif;
// FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
$caps = get_usermeta( $user->ID, $wpdb->table_prefix . 'capabilities');
$caps = get_usermeta( $user->ID, $wpdb->prefix . 'capabilities');
if ( empty($caps) || defined('RESET_CAPS') ) {
$level = get_usermeta($user->ID, $wpdb->table_prefix . 'user_level');
$level = get_usermeta($user->ID, $wpdb->prefix . 'user_level');
$role = translate_level_to_role($level);
update_usermeta( $user->ID, $wpdb->table_prefix . 'capabilities', array($role => true) );
update_usermeta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
}
endforeach;

View File

@ -106,7 +106,7 @@ class wpdbBackup {
global $wpdb;
$datum = date("Ymd_B");
$backup_filename = DB_NAME . '_' . $wpdb->table_prefix . $datum . '.sql';
$backup_filename = DB_NAME . '_' . $wpdb->prefix . $datum . '.sql';
if ($this->gzip()) $backup_filename .= '.gz';
echo "<div class='wrap'>";
@ -558,7 +558,7 @@ class wpdbBackup {
global $wpdb;
$datum = date("Ymd_B");
$wp_backup_filename = DB_NAME . '_' . $wpdb->table_prefix . $datum . '.sql';
$wp_backup_filename = DB_NAME . '_' . $wpdb->prefix . $datum . '.sql';
if ($this->gzip()) {
$wp_backup_filename .= '.gz';
}
@ -720,7 +720,7 @@ class wpdbBackup {
// Simple table name storage
$wp_table_names = explode(',','categories,comments,linkcategories,links,options,post2cat,postmeta,posts,users,usermeta');
// Apply WP DB prefix to table names
$wp_table_names = array_map(create_function('$a', 'global $wpdb;return "{$wpdb->table_prefix}{$a}";'), $wp_table_names);
$wp_table_names = array_map(create_function('$a', 'global $wpdb;return "{$wpdb->prefix}{$a}";'), $wp_table_names);
$other_tables = array();
$also_backup = array();
@ -867,7 +867,7 @@ class wpdbBackup {
global $wpdb;
$wp_table_names = explode(',','categories,comments,linkcategories,links,options,post2cat,postmeta,posts,users,usermeta');
$wp_table_names = array_map(create_function('$a', 'global $wpdb;return "{$wpdb->table_prefix}{$a}";'), $wp_table_names);
$wp_table_names = array_map(create_function('$a', 'global $wpdb;return "{$wpdb->prefix}{$a}";'), $wp_table_names);
$all_tables = $wpdb->get_results("SHOW TABLES", ARRAY_N);
$all_tables = array_map(create_function('$a', 'return $a[0];'), $all_tables);
$core_tables = array_intersect($all_tables, $wp_table_names);

View File

@ -9,7 +9,7 @@ class WP_Roles {
function WP_Roles() {
global $wpdb;
$this->role_key = $wpdb->table_prefix . 'user_roles';
$this->role_key = $wpdb->prefix . 'user_roles';
$this->roles = get_option($this->role_key);
@ -144,7 +144,7 @@ class WP_User {
}
$this->id = $this->ID;
$this->cap_key = $wpdb->table_prefix . 'capabilities';
$this->cap_key = $wpdb->prefix . 'capabilities';
$this->caps = &$this->{$this->cap_key};
if ( ! is_array($this->caps) )
$this->caps = array();
@ -186,7 +186,7 @@ class WP_User {
}
function set_role($role) {
foreach($this->roles as $oldrole)
foreach($this->roles as $oldrole)
unset($this->caps[$oldrole]);
$this->caps[$role] = true;
$this->roles = array($role => true);
@ -207,7 +207,7 @@ class WP_User {
function update_user_level_from_caps() {
global $wpdb;
$this->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0);
update_usermeta($this->id, $wpdb->table_prefix.'user_level', $this->user_level);
update_usermeta($this->id, $wpdb->prefix.'user_level', $this->user_level);
}
function add_cap($cap, $grant = true) {