[wp-trac] [WordPress Trac] #20285: Author meta fields aren't displaying correctly due to broken logic
WordPress Trac
wp-trac at lists.automattic.com
Fri Mar 23 04:27:43 UTC 2012
#20285: Author meta fields aren't displaying correctly due to broken logic
--------------------------+-----------------------------
Reporter: FredWu | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version: 3.3.1
Severity: major | Keywords: has-patch
--------------------------+-----------------------------
Some authors have missing meta data even though the data are in the
database. For example, some authors' description/biography are empty when
retrieving them from `the_author_meta('description')`, even though
`$authordata->description` from the function shows the data correctly.
This is caused by a bug in `wp-includes/author-template.php`, starting
from line 99:
{{{
function get_the_author_meta($field = '', $user_id = false) {
if ( ! $user_id )
global $authordata;
else
$authordata = get_userdata( $user_id );
var_dump($authordata);
// Keys used as object vars cannot have dashes.
$field = str_replace('-', '', $field);
$field = strtolower($field);
$user_field = "user_$field";
if ( 'id' == $field )
$value = isset($authordata->ID) ? (int)$authordata->ID :
0;
elseif ( isset($authordata->$user_field) )
$value = $authordata->$user_field;
else
$value = isset($authordata->$field) ? $authordata->$field
: '';
return apply_filters('get_the_author_' . $field, $value,
$user_id);
}
}}}
`elseif ( isset($authordata->$user_field) )` is the problem, because for
some users this field is set, but is empty, so the system never gets
through to the real 'description' field.
I've attached a patch that fixes this.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20285>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list