Skip to content

Commit fe7cb19

Browse files
committed
Give better instructions when installing over an existing users table. Fixes WordPress#9569 based on patch from coffee2code.
git-svn-id: https://develop.svn.wordpress.org/trunk@11326 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 356592e commit fe7cb19

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

wp-admin/includes/upgrade.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
if ( !function_exists('wp_install') ) :
2222
/**
23-
* {@internal Missing Short Description}}
23+
* Installs the blog
2424
*
2525
* {@internal Missing Long Description}}
2626
*
@@ -31,7 +31,7 @@
3131
* @param string $user_email User's email.
3232
* @param bool $public Whether blog is public.
3333
* @param null $deprecated Optional. Not used.
34-
* @return array Array keys 'url', 'user_id', 'password'.
34+
* @return array Array keys 'url', 'user_id', 'password', 'password_message'.
3535
*/
3636
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') {
3737
global $wp_rewrite;
@@ -59,10 +59,12 @@ function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='
5959
$user_id = username_exists($user_name);
6060
if ( !$user_id ) {
6161
$random_password = wp_generate_password();
62+
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
6263
$user_id = wp_create_user($user_name, $random_password, $user_email);
6364
update_usermeta($user_id, 'default_password_nag', true);
6465
} else {
65-
$random_password = __('User already exists. Password inherited.');
66+
$random_password = '';
67+
$message = __('User already exists. Password inherited.');
6668
}
6769

6870
$user = new WP_User($user_id);
@@ -76,7 +78,7 @@ function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='
7678

7779
wp_cache_flush();
7880

79-
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
81+
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password, 'password_message' => $message);
8082
}
8183
endif;
8284

wp-admin/install.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ function display_setup_form( $error = null ) {
136136
</tr>
137137
<tr>
138138
<th><?php _e('Password'); ?></th>
139-
<td><code><?php echo $password; ?></code><br />
140-
<?php echo '<p>'.__('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.').'</p>'; ?></td>
139+
<td><?php if ( !empty( $password ) ) {
140+
echo '<code>'. $password .'</code><br />';
141+
}
142+
echo '<p>'. $password_message .'</p>'; ?></td>
141143
</tr>
142144
</table>
143145

0 commit comments

Comments
 (0)