diff options
author | Nathaniel Guse <nathaniel.guse@gmail.com> | 2013-04-25 10:58:48 -0500 |
---|---|---|
committer | Nathaniel Guse <nathaniel.guse@gmail.com> | 2013-04-25 10:58:48 -0500 |
commit | 42cfb7264dec3a1e8f141ff40b17b841e5c998cc (patch) | |
tree | aec662a427dbe06c3488304c52abd26c341a9e1e | |
parent | 2bf01098d2c3e45824448642dde9f1469ec6e588 (diff) | |
download | forums-42cfb7264dec3a1e8f141ff40b17b841e5c998cc.tar forums-42cfb7264dec3a1e8f141ff40b17b841e5c998cc.tar.gz forums-42cfb7264dec3a1e8f141ff40b17b841e5c998cc.tar.bz2 forums-42cfb7264dec3a1e8f141ff40b17b841e5c998cc.tar.xz forums-42cfb7264dec3a1e8f141ff40b17b841e5c998cc.zip |
[ticket/11237] Fix PHP error in acp_prune.php
Also making the code a bit more efficient (removing one SQL query)
PHPBB3-11237
-rw-r--r-- | phpBB/includes/acp/acp_prune.php | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index a5dc02849a..54ffe24594 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -491,11 +491,12 @@ class acp_prune if ($group_id) { - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . ' - WHERE group_id = ' . (int) $group_id . ' - AND user_pending = 0 - AND ' . $db->sql_in_set('user_id', $user_ids, false, true); + $sql = 'SELECT u.user_id, u.username + FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u + WHERE ug.group_id = ' . (int) $group_id . ' + AND ug.user_pending = 0 + AND ' . $db->sql_in_set('ug.user_id', $user_ids, false, true) . ' + AND u.user_id = ug.user_id'; $result = $db->sql_query($sql); // we're performing an intersection operation, so all the relevant users @@ -504,24 +505,19 @@ class acp_prune $user_ids = $usernames = array(); while ($row = $db->sql_fetchrow($result)) { - $user_ids[] = $row['poster_id']; + $user_ids[] = $row['user_id']; + $usernames[$row['user_id']] = $row['username']; } $db->sql_freeresult($result); - - // only get usernames if they are needed (not part of some later query) - if (!$posts_on_queue) - { - // this is an additional query aginst the users table - user_get_id_name($user_ids, $usernames); - } } if ($posts_on_queue) { - $sql = 'SELECT poster_id, COUNT(post_id) AS queue_posts - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('poster_id', $user_ids, false, true) . ' - GROUP BY poster_id + $sql = 'SELECT u.user_id, u.username, COUNT(p.post_id) AS queue_posts + FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u + WHERE ' . $db->sql_in_set('p.poster_id', $user_ids, false, true) . ' + AND u.user_id = p.poster_id + GROUP BY p.poster_id HAVING queue_posts ' . $key_match[$queue_select] . ' ' . $posts_on_queue; $result = $db->sql_query($result); @@ -529,12 +525,10 @@ class acp_prune $user_ids = $usernames = array(); while ($row = $db->sql_fetchrow($result)) { - $user_ids[] = $row['poster_id']; + $user_ids[] = $row['user_id']; + $usernames[$row['user_id']] = $row['username']; } $db->sql_freeresult($result); - - // do an additional query to get the correct set of usernames - user_get_id_name($user_ids, $usernames); } } } |