Opened 15 years ago
Closed 15 years ago
#18458 closed defect (bug) (fixed)
calling is_user_logged_in() when logged-out throws PHP notice
| Reported by: | wonderboymusic | Owned by: | dd32 |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.3 |
| Component: | Warnings/Notices | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
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
@
15 years ago
- Milestone Awaiting Review → 3.3
- Owner set to
- Status new → 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Patch for this ticket