Opened 3 years ago
Last modified 3 years ago
#56229 new defect (bug)
Attempt to read property "user_nicename" on bool in link-template.php on line 265
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 6.0 |
| Component: | Permalinks | Keywords: | has-patch |
| Focuses: | Cc: |
Description (last modified by )
PHP Warning: Attempt to read property "user_nicename" on bool in .../wp-includes/link-template.php on line 265
if the $authordata == false from get_userdata() then this will produce the error. If the current post object is not set, it will produce the error.
Change History (3)
This ticket was mentioned in PR #3141 on WordPress/wordpress-develop by Tabrisrp.
3 years ago
#2
- Keywords has-patch added
Prevent PHP warning when reading user_nicename property from $authordata variable
Trac ticket: https://core.trac.wordpress.org/ticket/56229
#3
@
3 years ago
Thanks for the report and for the patch!
Plugins can replace the get_userdata function (and/or get_user_by). In case the custom function returns an unexpected type, could checking whether $authordata is an object be a better condition?
if ( is_object( $authordata ) ) {
$author = $authordata->user_nicename;
}
(line 265 is within
get_permalink())