Opened 16 years ago
Closed 16 years ago
#12555 closed defect (bug) (fixed)
PHP warning on Users screen when post count = 0
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.0 | Priority: | normal |
| Severity: | normal | Version: | 3.0 |
| Component: | Administration | Keywords: | has-patch commit |
| Focuses: | Cc: |
Description
I'm developing a wiki site that will consist of all pages (no posts).
When viewing the Users screen, there is a PHP warning at the top of the page:
Warning: Invalid argument supplied for foreach() in /home/xxx/public_html/xxx/wp-includes/user.php on line 180
If posts have a status other than "Published" or there are no posts at all, the warning displays. As soon as I publish one post, the warning goes away.
This happens in both single and multi-site 3.0 installs.
This is a result of the change to user.php in changeset 13576 in function count_many_users_posts().
function count_many_users_posts($users) {
global $wpdb;
if (0 == count($users))
return array();
$userlist = implode(',', $users);
$where = get_posts_by_author_sql('post');
$result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N );
$count = array();
foreach($result as $row) {
$count[$row[0]] = $row[1];
}
foreach($users as $id) {
$id = (string) $id;
if (!isset($count[$id]))
$count[$id] = 0;
}
return $count;
}
Attachments (2)
Change History (7)
#2
@
16 years ago
- Keywords needs-patch added
- Resolution fixed deleted
- Status changed from closed to reopened
#3
@
16 years ago
- Keywords has-patch added; needs-patch removed
- Owner set to nacin
- Status changed from reopened to assigned
Note: See
TracTickets for help on using
tickets.
(In [13617]) Fix warning in users.php. Fixes #12555