Changes in trunk/wp-includes/pluggable.php [19030:20691]
- File:
-
- 1 edited
-
trunk/wp-includes/pluggable.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/pluggable.php
r19030 r20691 28 28 global $current_user; 29 29 30 if ( isset( $current_user) && ($id == $current_user->ID) )30 if ( isset( $current_user ) && ( $current_user instanceof WP_User ) && ( $id == $current_user->ID ) ) 31 31 return $current_user; 32 32 33 $current_user = new WP_User( $id, $name);34 35 setup_userdata( $current_user->ID);33 $current_user = new WP_User( $id, $name ); 34 35 setup_userdata( $current_user->ID ); 36 36 37 37 do_action('set_current_user'); … … 75 75 global $current_user; 76 76 77 if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) 77 if ( ! empty( $current_user ) ) { 78 if ( $current_user instanceof WP_User ) 79 return; 80 81 // Upgrade stdClass to WP_User 82 if ( is_object( $current_user ) && isset( $current_user->ID ) ) { 83 $cur_id = $current_user->ID; 84 $current_user = null; 85 wp_set_current_user( $cur_id ); 86 return; 87 } 88 89 // $current_user has a junk value. Force to WP_User with ID 0. 90 $current_user = null; 91 wp_set_current_user( 0 ); 78 92 return false; 79 80 if ( ! empty($current_user) ) 81 return; 93 } 94 95 if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) { 96 wp_set_current_user( 0 ); 97 return false; 98 } 82 99 83 100 if ( ! $user = wp_validate_auth_cookie() ) { 84 if ( is_blog_admin() || is_network_admin() || empty( $_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {85 wp_set_current_user( 0);101 if ( is_blog_admin() || is_network_admin() || empty( $_COOKIE[LOGGED_IN_COOKIE] ) || !$user = wp_validate_auth_cookie( $_COOKIE[LOGGED_IN_COOKIE], 'logged_in' ) ) { 102 wp_set_current_user( 0 ); 86 103 return false; 87 104 } 88 105 } 89 106 90 wp_set_current_user( $user);107 wp_set_current_user( $user ); 91 108 } 92 109 endif; … … 112 129 * @since 2.8.0 113 130 * 114 * @param string $field The field to retrieve the user with. id | slug | email | login115 * @param int|string $value A value for $field. A user ID, slug, email address, or login name.131 * @param string $field The field to retrieve the user with. id | slug | email | login 132 * @param int|string $value A value for $field. A user ID, slug, email address, or login name. 116 133 * @return bool|object False on failure, WP_User object on success 117 134 */ … … 140 157 global $wpdb; 141 158 142 $clean = array(); 143 foreach ( $user_ids as $id ) { 144 $id = (int) $id; 145 if ( !wp_cache_get( $id, 'users' ) ) { 146 $clean[] = $id; 147 } 148 } 159 $clean = _get_non_cached_ids( $user_ids, 'users' ); 149 160 150 161 if ( empty( $clean ) ) … … 716 727 $user = wp_get_current_user(); 717 728 718 if ( empty( $user->ID) )729 if ( ! $user->exists() ) 719 730 return false; 720 731 … … 830 841 $result = wp_verify_nonce( $nonce, $action ); 831 842 832 if ( $die && false == $result ) 833 die('-1'); 843 if ( $die && false == $result ) { 844 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) 845 wp_die( -1 ); 846 else 847 die( '-1' ); 848 } 834 849 835 850 do_action('check_ajax_referer', $action, $result); … … 930 945 * 931 946 * @param string $location The redirect to validate 932 * @param string $default The value to return i s$location is not allowed947 * @param string $default The value to return if $location is not allowed 933 948 * @return string redirect-sanitized URL 934 949 **/ … … 1277 1292 if ( !function_exists('wp_salt') ) : 1278 1293 /** 1279 * Get salt to add to hashes to help prevent attacks. 1280 * 1281 * The secret key is located in two places: the database in case the secret key 1282 * isn't defined in the second place, which is in the wp-config.php file. If you 1283 * are going to set the secret key, then you must do so in the wp-config.php 1284 * file. 1285 * 1286 * The secret key in the database is randomly generated and will be appended to 1287 * the secret key that is in wp-config.php file in some instances. It is 1288 * important to have the secret key defined or changed in wp-config.php. 1289 * 1290 * If you have installed WordPress 2.5 or later, then you will have the 1291 * SECRET_KEY defined in the wp-config.php already. You will want to change the 1292 * value in it because hackers will know what it is. If you have upgraded to 1293 * WordPress 2.5 or later version from a version before WordPress 2.5, then you 1294 * should add the constant to your wp-config.php file. 1295 * 1296 * Below is an example of how the SECRET_KEY constant is defined with a value. 1297 * You must not copy the below example and paste into your wp-config.php. If you 1298 * need an example, then you can have a 1299 * {@link https://api.wordpress.org/secret-key/1.1/ secret key created} for you. 1294 * Get salt to add to hashes. 1295 * 1296 * Salts are created using secret keys. Secret keys are located in two places: 1297 * in the database and in the wp-config.php file. The secret key in the database 1298 * is randomly generated and will be appended to the secret keys in wp-config.php. 1299 * 1300 * The secret keys in wp-config.php should be updated to strong, random keys to maximize 1301 * security. Below is an example of how the secret key constants are defined. 1302 * Do not paste this example directly into wp-config.php. Instead, have a 1303 * {@link https://api.wordpress.org/secret-key/1.1/salt/ secret key created} just 1304 * for you. 1300 1305 * 1301 1306 * <code> 1302 * define('SECRET_KEY', 'mAry1HadA15|\/|b17w55w1t3asSn09w'); 1307 * define('AUTH_KEY', ' Xakm<o xQy rw4EMsLKM-?!T+,PFF})H4lzcW57AF0U@N@< >M%G4Yt>f`z]MON'); 1308 * define('SECURE_AUTH_KEY', 'LzJ}op]mr|6+![P}Ak:uNdJCJZd>(Hx.-Mh#Tz)pCIU#uGEnfFz|f ;;eU%/U^O~'); 1309 * define('LOGGED_IN_KEY', '|i|Ux`9<p-h$aFf(qnT:sDO:D1P^wZ$$/Ra@miTJi9G;ddp_<q}6H1)o|a +&JCM'); 1310 * define('NONCE_KEY', '%:R{[P|,s.KuMltH5}cI;/k<Gx~j!f0I)m_sIyu+&NJZ)-iO>z7X>QYR0Z_XnZ@|'); 1311 * define('AUTH_SALT', 'eZyT)-Naw]F8CwA*VaW#q*|.)g@o}||wf~@C-YSt}(dh_r6EbI#A,y|nU2{B#JBW'); 1312 * define('SECURE_AUTH_SALT', '!=oLUTXh,QW=H `}`L|9/^4-3 STz},T(w}W<I`.JjPi)<Bmf1v,HpGe}T1:Xt7n'); 1313 * define('LOGGED_IN_SALT', '+XSqHc;@Q*K_b|Z?NC[3H!!EONbh.n<+=uKR:>*c(u`g~EJBf#8u#R{mUEZrozmm'); 1314 * define('NONCE_SALT', 'h`GXHhD>SLWVfg1(1(N{;.V!MoE(SfbA_ksP@&`+AycHcAV$+?@3q+rxV{%^VyKT'); 1303 1315 * </code> 1304 1316 * 1305 1317 * Salting passwords helps against tools which has stored hashed values of 1306 * common dictionary strings. The added values makes it harder to crack if given 1307 * salt string is not weak. 1318 * common dictionary strings. The added values makes it harder to crack. 1308 1319 * 1309 1320 * @since 2.5 1310 * @link https://api.wordpress.org/secret-key/1.1/ Create a Secret Key for wp-config.php 1311 * 1312 * @param string $scheme Authentication scheme 1321 * 1322 * @link https://api.wordpress.org/secret-key/1.1/salt/ Create secrets for wp-config.php 1323 * 1324 * @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce) 1313 1325 * @return string Salt value 1314 1326 */ 1315 function wp_salt($scheme = 'auth') { 1316 global $wp_default_secret_key; 1317 $secret_key = ''; 1318 if ( defined('SECRET_KEY') && ('' != SECRET_KEY) && ( $wp_default_secret_key != SECRET_KEY) ) 1319 $secret_key = SECRET_KEY; 1320 1321 if ( 'auth' == $scheme ) { 1322 if ( defined('AUTH_KEY') && ('' != AUTH_KEY) && ( $wp_default_secret_key != AUTH_KEY) ) 1323 $secret_key = AUTH_KEY; 1324 1325 if ( defined('AUTH_SALT') && ('' != AUTH_SALT) && ( $wp_default_secret_key != AUTH_SALT) ) { 1326 $salt = AUTH_SALT; 1327 } elseif ( defined('SECRET_SALT') && ('' != SECRET_SALT) && ( $wp_default_secret_key != SECRET_SALT) ) { 1328 $salt = SECRET_SALT; 1329 } else { 1330 $salt = get_site_option('auth_salt'); 1331 if ( empty($salt) ) { 1332 $salt = wp_generate_password( 64, true, true ); 1333 update_site_option('auth_salt', $salt); 1327 function wp_salt( $scheme = 'auth' ) { 1328 static $cached_salts = array(); 1329 if ( isset( $cached_salts[ $scheme ] ) ) 1330 return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme ); 1331 1332 static $duplicated_keys; 1333 if ( null === $duplicated_keys ) { 1334 $duplicated_keys = array( 'put your unique phrase here' => true ); 1335 foreach ( array( 'AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET' ) as $first ) { 1336 foreach ( array( 'KEY', 'SALT' ) as $second ) { 1337 if ( ! defined( "{$first}_{$second}" ) ) 1338 continue; 1339 $value = constant( "{$first}_{$second}" ); 1340 $duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] ); 1334 1341 } 1335 1342 } 1336 } elseif ( 'secure_auth' == $scheme ) { 1337 if ( defined('SECURE_AUTH_KEY') && ('' != SECURE_AUTH_KEY) && ( $wp_default_secret_key != SECURE_AUTH_KEY) ) 1338 $secret_key = SECURE_AUTH_KEY; 1339 1340 if ( defined('SECURE_AUTH_SALT') && ('' != SECURE_AUTH_SALT) && ( $wp_default_secret_key != SECURE_AUTH_SALT) ) { 1341 $salt = SECURE_AUTH_SALT; 1342 } else { 1343 $salt = get_site_option('secure_auth_salt'); 1344 if ( empty($salt) ) { 1345 $salt = wp_generate_password( 64, true, true ); 1346 update_site_option('secure_auth_salt', $salt); 1347 } 1348 } 1349 } elseif ( 'logged_in' == $scheme ) { 1350 if ( defined('LOGGED_IN_KEY') && ('' != LOGGED_IN_KEY) && ( $wp_default_secret_key != LOGGED_IN_KEY) ) 1351 $secret_key = LOGGED_IN_KEY; 1352 1353 if ( defined('LOGGED_IN_SALT') && ('' != LOGGED_IN_SALT) && ( $wp_default_secret_key != LOGGED_IN_SALT) ) { 1354 $salt = LOGGED_IN_SALT; 1355 } else { 1356 $salt = get_site_option('logged_in_salt'); 1357 if ( empty($salt) ) { 1358 $salt = wp_generate_password( 64, true, true ); 1359 update_site_option('logged_in_salt', $salt); 1360 } 1361 } 1362 } elseif ( 'nonce' == $scheme ) { 1363 if ( defined('NONCE_KEY') && ('' != NONCE_KEY) && ( $wp_default_secret_key != NONCE_KEY) ) 1364 $secret_key = NONCE_KEY; 1365 1366 if ( defined('NONCE_SALT') && ('' != NONCE_SALT) && ( $wp_default_secret_key != NONCE_SALT) ) { 1367 $salt = NONCE_SALT; 1368 } else { 1369 $salt = get_site_option('nonce_salt'); 1370 if ( empty($salt) ) { 1371 $salt = wp_generate_password( 64, true, true ); 1372 update_site_option('nonce_salt', $salt); 1343 } 1344 1345 $key = $salt = ''; 1346 if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) 1347 $key = SECRET_KEY; 1348 if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) 1349 $salt = SECRET_SALT; 1350 1351 if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) ) ) { 1352 foreach ( array( 'key', 'salt' ) as $type ) { 1353 $const = strtoupper( "{$scheme}_{$type}" ); 1354 if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) { 1355 $$type = constant( $const ); 1356 } elseif ( ! $$type ) { 1357 $$type = get_site_option( "{$scheme}_{$type}" ); 1358 if ( ! $$type ) { 1359 $$type = wp_generate_password( 64, true, true ); 1360 update_site_option( "{$scheme}_{$type}", $$type ); 1361 } 1373 1362 } 1374 1363 } 1375 1364 } else { 1376 // ensure each auth scheme has its own unique salt 1377 $salt = hash_hmac('md5', $scheme, $secret_key); 1378 } 1379 1380 return apply_filters('salt', $secret_key . $salt, $scheme); 1365 if ( ! $key ) { 1366 $key = get_site_option( 'secret_key' ); 1367 if ( ! $key ) { 1368 $key = wp_generate_password( 64, true, true ); 1369 update_site_option( 'secret_key', $key ); 1370 } 1371 } 1372 $salt = hash_hmac( 'md5', $scheme, $key ); 1373 } 1374 1375 $cached_salts[ $scheme ] = $key . $salt; 1376 return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme ); 1381 1377 } 1382 1378 endif; … … 1419 1415 require_once( ABSPATH . 'wp-includes/class-phpass.php'); 1420 1416 // By default, use the portable hash from phpass 1421 $wp_hasher = new PasswordHash(8, TRUE);1417 $wp_hasher = new PasswordHash(8, true); 1422 1418 } 1423 1419 … … 1467 1463 require_once( ABSPATH . 'wp-includes/class-phpass.php'); 1468 1464 // By default, use the portable hash from phpass 1469 $wp_hasher = new PasswordHash(8, TRUE);1465 $wp_hasher = new PasswordHash(8, true); 1470 1466 } 1471 1467 … … 1630 1626 1631 1627 if ( !empty($email) ) 1632 $email_hash = md5( strtolower( $email) );1628 $email_hash = md5( strtolower( trim( $email ) ) ); 1633 1629 1634 1630 if ( is_ssl() ) { … … 1648 1644 $default = ''; 1649 1645 elseif ( 'gravatar_default' == $default ) 1650 $default = "$host/avatar/ s={$size}";1646 $default = "$host/avatar/?s={$size}"; 1651 1647 elseif ( empty($email) ) 1652 1648 $default = "$host/avatar/?d=$default&s={$size}"; … … 1710 1706 $right_string = normalize_whitespace($right_string); 1711 1707 1712 $left_lines = split("\n", $left_string);1713 $right_lines = split("\n", $right_string);1708 $left_lines = explode("\n", $left_string); 1709 $right_lines = explode("\n", $right_string); 1714 1710 1715 1711 $text_diff = new Text_Diff($left_lines, $right_lines);
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)