mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Roles/Caps: Return same result from current_user_can and user_can().
Ensure `current_user_can()` and `user_can()` return the same results for logged out users. For core capabilities this changes `user_can( 0, 'exist' )` to return `true` rather than `false` in line with `current_user_can( 'exist' )` for logged out users. Convert `current_user_can()` and `current_user_can_for_blog()` to wrapper functions ultimately calling `user_can()`. Add anonymous user to primitive capability checks as appropriate. Convert `Tests_User_Capabilities::test_other_caps_for_all_roles()` to use a data provider and add tests to check whether user exists in the database (`WP_User::exists()`) as that intentionally differs from the `exist` capability. Props jjj, johnbillion, peterwilsoncc, SergeyBiryukov, TimothyBlynJacobs. Fixes #52076. git-svn-id: https://develop.svn.wordpress.org/trunk@50490 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -167,6 +167,9 @@ class WP_User {
|
||||
* @param int $site_id Optional. The site ID to initialize for.
|
||||
*/
|
||||
public function init( $data, $site_id = '' ) {
|
||||
if ( ! isset( $data->ID ) ) {
|
||||
$data->ID = 0;
|
||||
}
|
||||
$this->data = $data;
|
||||
$this->ID = (int) $data->ID;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user