#19769 closed defect (bug) (fixed)
$userdata is not empty for anonymous requests
Reported by: | MattyRob | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.3.2 | Priority: | normal |
Severity: | normal | Version: | 3.3.1 |
Component: | Users | Keywords: | has-patch dev-feedback |
Focuses: | Cc: |
Description
When an anonymous user visit a WordPress 3.3.x installation (i.e. a user who has not logged in) the $userdata global variable is set but virtually unpopulated.
In previous versions of WordPress (3.2.1 checked) the $userdata variable returns NULL. In the 3.3 branch it returns the following:
object(WP_User)#251 (7) { ["data"]=> NULL ["ID"]=> int(0) ["caps"]=> array(0) { } ["cap_key"]=> NULL ["roles"]=> array(0) { } ["allcaps"]=> array(0) { } ["filter"]=> NULL }
Is this expected behaviour? I would have though $userdata should be NULL for visits from users who are not logged in.
I tested with this simple plugin:
function ud_check() { global $userdata; var_dump($userdata); } add_action('shutdown', 'ud_check');
Attachments (3)
Change History (13)
#2
in reply to:
↑ 1
@
13 years ago
Replying to linuxologos:
Possibly related: #19595.
Thanks, I'd seen that ticket but that was more about the data for a user not being fully populated. This is more about the data being there when perhaps it should not be (unless this is a new feature and by design).
#3
@
13 years ago
- Milestone changed from Awaiting Review to 3.3.2
Yeah, this should be fixed somehow.
#4
follow-up:
↓ 5
@
13 years ago
- Keywords has-patch dev-feedback needs-testing added
This is certainly a new area of WordPress code to me but it seems to be something to do with maybe cookies and setting wp_set_current_user(0);
I can get a NULL returned with the attached pitch but I am not sure if this will have additional consequences, so needs a second opinion from the core devs.
#5
in reply to:
↑ 4
@
13 years ago
- Version changed from 3.3 to 3.3.1
Replying to MattyRob:
I can get a NULL returned with the attached patch
Doesn't work for me. $value === 0
is already caught by the conditional before checking if $value is falsey.
Attached patch to set $userdata to null in setup_userdata().
The bug is in 3.3.1 only and was caused by [19625] for #19595.
#7
@
13 years ago
- Keywords needs-testing removed
I've tested this new patch and it fixes the original problem reported. needs-testing removed, unable to add tested or commit
Possibly related: #19595.