Opened 14 years ago
Closed 14 years ago
#18458 closed defect (bug) (fixed)
calling is_user_logged_in() when logged-out throws PHP notice
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Warnings/Notices | Keywords: | has-patch |
Focuses: | Cc: |
Description
calling wp_get_current_user() when no user is logged in does not produce a User object, yet is_user_logged_in() tries to read the the id property of $user on every call to this function, whether an object exists or not.
This produces the following notice in the logs when error_reporting is set to -1
PHP Notice: Trying to get property of non-object in /Users/scott/Sites/emusic/trunk/wordpress/wp-includes/pluggable.php on line 758
The function is triggered by all calls to $WP_Query->get_posts() and will produce an obscene number of notices in error logs on high traffic sites. As an example, every XML-RPC made on eMusic.com produces this Notice in our logs.
Attachments (1)
Change History (3)
#1
@
14 years ago
- Milestone changed from Awaiting Review to 3.3
- Owner set to dd32
- Status changed from new to accepted
On non-XML-RPC pageloads, That shouldn't produce a notice, as $current_user should be an object similar to this:
object(WP_User)[723] public 'data' => null public 'ID' => int 0 public 'caps' => array empty public 'cap_key' => null public 'roles' => array empty public 'allcaps' => array empty public 'filter' => null
However, XML-RPC does have that issue.
Patch for this ticket