diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 31b517eb84..248adb2b7c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -590,7 +590,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ if ($mode == 'all') { - if ($forum_id === false || !sizeof($forum_id)) + if (empty($forum_id)) { // Mark all forums read (index page) /* @var $phpbb_notifications \phpbb\notification\manager */ @@ -715,7 +715,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } $db->sql_freeresult($result); - if (sizeof($sql_update)) + if (count($sql_update)) { $sql = 'UPDATE ' . FORUMS_TRACK_TABLE . " SET mark_time = $post_time @@ -851,7 +851,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // We get the ten most minimum stored time offsets and its associated topic ids $time_keys = array(); - for ($i = 0; $i < 10 && sizeof($tracking['t']); $i++) + for ($i = 0; $i < 10 && count($tracking['t']); $i++) { $min_value = min($tracking['t']); $m_tkey = array_search($min_value, $tracking['t']); @@ -947,7 +947,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $ $topic_ids = array_diff($topic_ids, array_keys($last_read)); - if (sizeof($topic_ids)) + if (count($topic_ids)) { $mark_time = array(); @@ -999,7 +999,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis $topic_ids = array_diff($topic_ids, array_keys($last_read)); - if (sizeof($topic_ids)) + if (count($topic_ids)) { $sql = 'SELECT forum_id, mark_time FROM ' . FORUMS_TRACK_TABLE . " @@ -1026,7 +1026,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis { global $tracking_topics; - if (!isset($tracking_topics) || !sizeof($tracking_topics)) + if (!isset($tracking_topics) || !count($tracking_topics)) { $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); @@ -1053,7 +1053,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis $topic_ids = array_diff($topic_ids, array_keys($last_read)); - if (sizeof($topic_ids)) + if (count($topic_ids)) { $mark_time = array(); @@ -1395,7 +1395,7 @@ function tracking_unserialize($string, $max_depth = 3) switch ($string[$i]) { case '(': - if (sizeof($stack) >= $max_depth) + if (count($stack) >= $max_depth) { die('Invalid data supplied'); } @@ -1449,7 +1449,7 @@ function tracking_unserialize($string, $max_depth = 3) } } - if (sizeof($stack) != 0 || ($mode != 0 && $mode != 3)) + if (count($stack) != 0 || ($mode != 0 && $mode != 3)) { die('Invalid data supplied'); } @@ -2663,9 +2663,9 @@ function parse_cfg_file($filename, $lines = false) { $value = ''; } - else if (($value[0] == "'" && $value[sizeof($value) - 1] == "'") || ($value[0] == '"' && $value[sizeof($value) - 1] == '"')) + else if (($value[0] == "'" && $value[strlen($value) - 1] == "'") || ($value[0] == '"' && $value[strlen($value) - 1] == '"')) { - $value = htmlspecialchars(substr($value, 1, sizeof($value)-2)); + $value = htmlspecialchars(substr($value, 1, strlen($value)-2)); } else { @@ -2994,7 +2994,7 @@ function phpbb_inet_pton($address) if (preg_match(get_preg_expression('ipv6'), $address)) { $parts = explode(':', $address); - $missing_parts = 8 - sizeof($parts) + 1; + $missing_parts = 8 - count($parts) + 1; if (substr($address, 0, 2) === '::') { @@ -3011,7 +3011,7 @@ function phpbb_inet_pton($address) if (preg_match(get_preg_expression('ipv4'), $last_part)) { - $parts[sizeof($parts) - 1] = ''; + $parts[count($parts) - 1] = ''; $last_part = phpbb_inet_pton($last_part); $embedded_ipv4 = true; --$missing_parts; @@ -3023,7 +3023,7 @@ function phpbb_inet_pton($address) { $ret .= str_pad($part, 4, '0', STR_PAD_LEFT); } - else if ($i && $i < sizeof($parts) - 1) + else if ($i && $i < count($parts) - 1) { $ret .= str_repeat('0000', $missing_parts); } @@ -3619,7 +3619,7 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum' // Need caps version of $item for language-strings $item_caps = strtoupper($item); - if (sizeof($online_users['online_users'])) + if (count($online_users['online_users'])) { $sql_ary = array( 'SELECT' => 'u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour', diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 929b7739a6..d62c7a21b3 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -167,7 +167,7 @@ function size_select_options($size_compare) $s_size_options = ''; - for ($i = 0, $size = sizeof($size_types_text); $i < $size; $i++) + for ($i = 0, $size = count($size_types_text); $i < $size; $i++) { $selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : ''; $s_size_options .= ''; @@ -192,7 +192,7 @@ function group_select_options($group_id, $exclude_ids = false, $manage_founder = /** @var \phpbb\group\helper $group_helper */ $group_helper = $phpbb_container->get('group_helper'); - $exclude_sql = ($exclude_ids !== false && sizeof($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : ''; + $exclude_sql = ($exclude_ids !== false && count($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : ''; $sql_and = (!$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : ''; $sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : ''; @@ -747,7 +747,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s { $where_ids = (is_array($where_ids)) ? array_unique($where_ids) : array($where_ids); - if (!sizeof($where_ids)) + if (!count($where_ids)) { return array('topics' => 0, 'posts' => 0); } @@ -777,9 +777,9 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s } $db->sql_freeresult($result); - $return['topics'] = sizeof($topic_ids); + $return['topics'] = count($topic_ids); - if (!sizeof($topic_ids)) + if (!count($topic_ids)) { return $return; } @@ -837,7 +837,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s } $db->sql_freeresult($result); - if (sizeof($moved_topic_ids)) + if (count($moved_topic_ids)) { $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $moved_topic_ids); @@ -923,7 +923,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = $where_ids = array($where_ids); } - if (!sizeof($where_ids)) + if (!count($where_ids)) { return false; } @@ -974,7 +974,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = } $db->sql_freeresult($result); - if (!sizeof($post_ids)) + if (!count($post_ids)) { return false; } @@ -1018,7 +1018,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = unset($table_ary); // Adjust users post counts - if (sizeof($post_counts) && $post_count_sync) + if (count($post_counts) && $post_count_sync) { foreach ($post_counts as $poster_id => $substract) { @@ -1037,7 +1037,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = } // Remove topics now having no posts? - if (sizeof($topic_ids)) + if (count($topic_ids)) { $sql = 'SELECT topic_id FROM ' . POSTS_TABLE . ' @@ -1147,7 +1147,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = } // We actually remove topics now to not be inconsistent (the delete_topics function calls this function too) - if (sizeof($remove_topics) && $call_delete_topics) + if (count($remove_topics) && $call_delete_topics) { delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync, false); } @@ -1157,7 +1157,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = $phpbb_notifications->delete_notifications($delete_notifications_types, $post_ids); - return sizeof($post_ids); + return count($post_ids); } /** @@ -1210,7 +1210,7 @@ function delete_topic_shadows($forum_id, $sql_more = '', $auto_sync = true) $db->sql_query($sql); } } - while (sizeof($topic_ids) == $batch_size); + while (count($topic_ids) == $batch_size); if ($auto_sync) { @@ -1324,7 +1324,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // Do not sync the "global forum" $where_ids = array_diff($where_ids, array(0)); - if (!sizeof($where_ids)) + if (!count($where_ids)) { // Empty array with IDs. This means that we don't have any work to do. Just return. return; @@ -1338,7 +1338,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } else { - if (!sizeof($where_ids)) + if (!count($where_ids)) { return; } @@ -1377,7 +1377,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } $db->sql_freeresult($result); - if (!sizeof($topic_id_ary)) + if (!count($topic_id_ary)) { return; } @@ -1494,7 +1494,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $post_ids[] = $post_id; } - if (sizeof($post_ids)) + if (count($post_ids)) { $sql = 'UPDATE ' . POSTS_TABLE . ' SET post_reported = 1 - post_reported @@ -1540,7 +1540,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } $db->sql_freeresult($result); - if (sizeof($topic_ids)) + if (count($topic_ids)) { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET topic_reported = 1 - topic_reported @@ -1599,7 +1599,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $post_ids[] = $post_id; } - if (sizeof($post_ids)) + if (count($post_ids)) { $sql = 'UPDATE ' . POSTS_TABLE . ' SET post_attachment = 1 - post_attachment @@ -1645,7 +1645,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } $db->sql_freeresult($result); - if (sizeof($topic_ids)) + if (count($topic_ids)) { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET topic_attachment = 1 - topic_attachment @@ -1697,7 +1697,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } $db->sql_freeresult($result); - if (!sizeof($forum_ids)) + if (!count($forum_ids)) { break; } @@ -1736,7 +1736,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // 3: Get post count for each forum (optional) if ($sync_extra) { - if (sizeof($forum_ids) == 1) + if (count($forum_ids) == 1) { $sql = 'SELECT SUM(t.topic_posts_approved) AS forum_posts_approved, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted FROM ' . TOPICS_TABLE . ' t @@ -1756,7 +1756,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, while ($row = $db->sql_fetchrow($result)) { - $forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; + $forum_id = (count($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; $forum_data[$forum_id]['posts_approved'] = (int) $row['forum_posts_approved']; $forum_data[$forum_id]['posts_unapproved'] = (int) $row['forum_posts_unapproved']; @@ -1766,7 +1766,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } // 4: Get last_post_id for each forum - if (sizeof($forum_ids) == 1) + if (count($forum_ids) == 1) { $sql = 'SELECT MAX(t.topic_last_post_id) as last_post_id FROM ' . TOPICS_TABLE . ' t @@ -1786,7 +1786,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, while ($row = $db->sql_fetchrow($result)) { - $forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; + $forum_id = (count($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; $forum_data[$forum_id]['last_post_id'] = (int) $row['last_post_id']; @@ -1795,7 +1795,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_freeresult($result); // 5: Retrieve last_post infos - if (sizeof($post_ids)) + if (count($post_ids)) { $sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_time, p.post_username, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u @@ -1863,7 +1863,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } } - if (sizeof($sql_ary)) + if (count($sql_ary)) { $sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' @@ -1986,20 +1986,20 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } // Now we delete empty topics and orphan posts - if (sizeof($delete_posts)) + if (count($delete_posts)) { delete_posts('topic_id', array_keys($delete_posts), false); unset($delete_posts); } - if (!sizeof($topic_data)) + if (!count($topic_data)) { // If we get there, topic ids were invalid or topics did not contain any posts delete_topics($where_type, $where_ids, true); return; } - if (sizeof($delete_topics)) + if (count($delete_topics)) { $delete_topic_ids = array(); foreach ($delete_topics as $topic_id => $void) @@ -2042,7 +2042,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_freeresult($result); // Make sure shadow topics do link to existing topics - if (sizeof($moved_topics)) + if (count($moved_topics)) { $delete_topics = array(); @@ -2059,7 +2059,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } $db->sql_freeresult($result); - if (sizeof($delete_topics)) + if (count($delete_topics)) { delete_topics('topic_id', $delete_topics, false); } @@ -2082,7 +2082,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_freeresult($result); $sync_shadow_topics = array(); - if (sizeof($post_ids)) + if (count($post_ids)) { $sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u @@ -2135,7 +2135,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $shadow_topic_data = array(); // Update the information we collected - if (sizeof($sync_shadow_topics)) + if (count($sync_shadow_topics)) { foreach ($sync_shadow_topics as $sync_topic_id => $sql_ary) { @@ -2200,7 +2200,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } } - if (sizeof($sql_ary)) + if (count($sql_ary)) { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' @@ -2217,7 +2217,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // if some topics have been resync'ed then resync parent forums // except when we're only syncing a range, we don't want to sync forums during // batch processing. - if ($resync_parents && sizeof($resync_forums) && $where_type != 'range') + if ($resync_parents && count($resync_forums) && $where_type != 'range') { sync('forum', 'forum_id', array_values($resync_forums), true, true); } @@ -2239,7 +2239,7 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync $forum_id = array($forum_id); } - if (!sizeof($forum_id)) + if (!count($forum_id)) { return; } @@ -2402,7 +2402,7 @@ function phpbb_cache_moderators($db, $cache, $auth) $hold_ary = $auth->acl_user_raw_data(false, 'm_%', false); // Add users? - if (sizeof($hold_ary)) + if (!empty($hold_ary)) { // At least one moderative option warrants a display $ug_id_ary = array_keys($hold_ary); @@ -2447,7 +2447,7 @@ function phpbb_cache_moderators($db, $cache, $auth) } $db->sql_freeresult($result); - if (sizeof($hold_ary)) + if (count($hold_ary)) { // Get usernames... $sql = 'SELECT user_id, username @@ -2487,7 +2487,7 @@ function phpbb_cache_moderators($db, $cache, $auth) // Now to the groups... $hold_ary = $auth->acl_group_raw_data(false, 'm_%', false); - if (sizeof($hold_ary)) + if (!empty($hold_ary)) { $ug_id_ary = array_keys($hold_ary); @@ -2591,7 +2591,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false) { // update foes for some user - if (is_array($user_id) && sizeof($user_id)) + if (is_array($user_id) && count($user_id)) { $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' WHERE ' . $db->sql_in_set('zebra_id', $user_id) . ' @@ -2601,7 +2601,7 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false) } // update foes for some group - if (is_array($group_id) && sizeof($group_id)) + if (is_array($group_id) && count($group_id)) { // Grab group settings... $sql_ary = array( @@ -2635,7 +2635,7 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false) } $db->sql_freeresult($result); - if (!sizeof($groups)) + if (!count($groups)) { return; } @@ -2665,7 +2665,7 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false) } $db->sql_freeresult($result); - if (sizeof($users)) + if (count($users)) { $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' WHERE ' . $db->sql_in_set('zebra_id', $users) . ' @@ -2688,7 +2688,7 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false) } } - if (sizeof($perms)) + if (count($perms)) { $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' WHERE ' . $db->sql_in_set('zebra_id', array_unique($perms)) . ' @@ -2951,7 +2951,7 @@ function tidy_warnings() } $db->sql_freeresult($result); - if (sizeof($warning_list)) + if (count($warning_list)) { $db->sql_transaction('begin'); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 3dd4b3c2e5..f1e03869b4 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -170,7 +170,7 @@ function user_update_name($old_name, $new_name) * Adds an user * * @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded. -* @param string $cp_data custom profile fields, see custom_profile::build_insert_sql_array +* @param array $cp_data custom profile fields, see custom_profile::build_insert_sql_array * @param array $notifications_data The notifications settings for the new user * @return the new user's ID. */ @@ -260,7 +260,7 @@ function user_add($user_row, $cp_data = false, $notifications_data = null) $remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary)); // Now fill our sql array with the remaining vars - if (sizeof($remaining_vars)) + if (count($remaining_vars)) { foreach ($remaining_vars as $key) { @@ -289,7 +289,7 @@ function user_add($user_row, $cp_data = false, $notifications_data = null) $user_id = $db->sql_nextid(); // Insert Custom Profile Fields - if ($cp_data !== false && sizeof($cp_data)) + if ($cp_data !== false && count($cp_data)) { $cp_data['user_id'] = (int) $user_id; @@ -468,7 +468,7 @@ function user_delete($mode, $user_ids, $retain_username = true) } $db->sql_freeresult($result); - if (sizeof($report_posts)) + if (count($report_posts)) { $report_posts = array_unique($report_posts); $report_topics = array_unique($report_topics); @@ -488,7 +488,7 @@ function user_delete($mode, $user_ids, $retain_username = true) } $db->sql_freeresult($result); - if (sizeof($keep_report_topics)) + if (count($keep_report_topics)) { $report_topics = array_diff($report_topics, $keep_report_topics); } @@ -500,7 +500,7 @@ function user_delete($mode, $user_ids, $retain_username = true) WHERE ' . $db->sql_in_set('post_id', $report_posts); $db->sql_query($sql); - if (sizeof($report_topics)) + if (count($report_topics)) { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET topic_reported = 0 @@ -765,7 +765,7 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL) $user_id_ary = array($user_id_ary); } - if (!sizeof($user_id_ary)) + if (!count($user_id_ary)) { return; } @@ -823,7 +823,7 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL) $vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements'); extract($phpbb_dispatcher->trigger_event('core.user_active_flip_before', compact($vars))); - if (sizeof($sql_statements)) + if (count($sql_statements)) { foreach ($sql_statements as $user_id => $sql_ary) { @@ -901,7 +901,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas else { $ban_other = explode('-', $ban_len_other); - if (sizeof($ban_other) == 3 && ((int) $ban_other[0] < 9999) && + if (count($ban_other) == 3 && ((int) $ban_other[0] < 9999) && (strlen($ban_other[0]) == 4) && (strlen($ban_other[1]) == 2) && (strlen($ban_other[2]) == 2)) { $ban_end = max($current_time, $user->create_datetime() @@ -969,7 +969,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas } // Make sure we have been given someone to ban - if (!sizeof($sql_usernames)) + if (!count($sql_usernames)) { trigger_error('NO_USER_SPECIFIED', E_USER_WARNING); } @@ -980,7 +980,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas // Do not allow banning yourself, the guest account, or founders. $non_bannable = array($user->data['user_id'], ANONYMOUS); - if (sizeof($founder)) + if (count($founder)) { $sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), $non_bannable), true); } @@ -1120,14 +1120,14 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas continue; } - if (!sizeof($founder) || !in_array($ban_item, $founder)) + if (!count($founder) || !in_array($ban_item, $founder)) { $banlist_ary[] = $ban_item; } } } - if (sizeof($ban_list) == 0) + if (count($ban_list) == 0) { trigger_error('NO_EMAILS_DEFINED', E_USER_WARNING); } @@ -1174,7 +1174,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas $banlist_ary_tmp = array_intersect($banlist_ary, $banlist_ary_tmp); - if (sizeof($banlist_ary_tmp)) + if (count($banlist_ary_tmp)) { // One or more entities are already banned/excluded, delete the existing bans, so they can be re-inserted with the given new length $sql = 'DELETE FROM ' . BANLIST_TABLE . ' @@ -1188,7 +1188,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas $db->sql_freeresult($result); // We have some entities to ban - if (sizeof($banlist_ary)) + if (count($banlist_ary)) { $sql_ary = array(); @@ -1316,7 +1316,7 @@ function user_unban($mode, $ban) $unban_sql = array_map('intval', $ban); - if (sizeof($unban_sql)) + if (count($unban_sql)) { // Grab details of bans for logging information later switch ($mode) @@ -1580,7 +1580,7 @@ function validate_num($num, $optional = false, $min = 0, $max = 1E99) function validate_date($date_string, $optional = false) { $date = explode('-', $date_string); - if ((empty($date) || sizeof($date) != 3) && $optional) + if ((empty($date) || count($date) != 3) && $optional) { return false; } @@ -1602,7 +1602,7 @@ function validate_date($date_string, $optional = false) } } - if (sizeof($date) != 3 || !checkdate($date[1], $date[0], $date[2])) + if (count($date) != 3 || !checkdate($date[1], $date[0], $date[2])) { return 'INVALID'; } @@ -1942,7 +1942,7 @@ function validate_jabber($jid) $arr = explode('.', $realm); - if (sizeof($arr) == 0) + if (count($arr) == 0) { return 'WRONG_DATA'; } @@ -2266,7 +2266,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow $group_teampage = !empty($group_attributes['group_teampage']); unset($group_attributes['group_teampage']); - if (!sizeof($error)) + if (!count($error)) { $current_legend = \phpbb\groupposition\legend::GROUP_DISABLED; $current_teampage = \phpbb\groupposition\teampage::GROUP_DISABLED; @@ -2339,7 +2339,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow generate_text_for_storage($sql_ary['group_desc'], $sql_ary['group_desc_uid'], $sql_ary['group_desc_bitfield'], $sql_ary['group_desc_options'], $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies); } - if (sizeof($group_attributes)) + if (count($group_attributes)) { // Merge them with $sql_ary to properly update the group $sql_ary = array_merge($sql_ary, $group_attributes); @@ -2465,7 +2465,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow // Set user attributes $sql_ary = array(); - if (sizeof($group_attributes)) + if (count($group_attributes)) { // Go through the user attributes array, check if a group attribute matches it and then set it. ;) foreach ($user_attribute_ary as $attribute) @@ -2485,7 +2485,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow } } - if (sizeof($sql_ary) && sizeof($user_ary)) + if (count($sql_ary) && count($user_ary)) { group_set_user_default($group_id, $user_ary, $sql_ary); } @@ -2496,7 +2496,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow group_update_listings($group_id); } - return (sizeof($error)) ? $error : false; + return (count($error)) ? $error : false; } @@ -2661,7 +2661,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, // We need both username and user_id info $result = user_get_id_name($user_id_ary, $username_ary); - if (!sizeof($user_id_ary) || $result !== false) + if (empty($user_id_ary) || $result !== false) { return 'NO_USER'; } @@ -2689,7 +2689,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $add_id_ary = array_diff($user_id_ary, $add_id_ary); // If we have no users - if (!sizeof($add_id_ary) && !sizeof($update_id_ary)) + if (!count($add_id_ary) && !count($update_id_ary)) { return 'GROUP_USERS_EXIST'; } @@ -2697,7 +2697,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $db->sql_transaction('begin'); // Insert the new users - if (sizeof($add_id_ary)) + if (count($add_id_ary)) { $sql_ary = array(); @@ -2714,7 +2714,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $db->sql_multi_insert(USER_GROUP_TABLE, $sql_ary); } - if (sizeof($update_id_ary)) + if (count($update_id_ary)) { $sql = 'UPDATE ' . USER_GROUP_TABLE . ' SET group_leader = 1 @@ -2806,7 +2806,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, // We need both username and user_id info $result = user_get_id_name($user_id_ary, $username_ary); - if (!sizeof($user_id_ary) || $result !== false) + if (empty($user_id_ary) || $result !== false) { return 'NO_USER'; } @@ -2882,7 +2882,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, foreach ($special_group_data as $gid => $default_data_ary) { - if (isset($sql_where_ary[$gid]) && sizeof($sql_where_ary[$gid])) + if (isset($sql_where_ary[$gid]) && count($sql_where_ary[$gid])) { remove_default_rank($group_id, $sql_where_ary[$gid]); remove_default_avatar($group_id, $sql_where_ary[$gid]); @@ -3041,7 +3041,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna // We need both username and user_id info $result = user_get_id_name($user_id_ary, $username_ary); - if (!sizeof($user_id_ary) || $result !== false) + if (empty($user_id_ary) || $result !== false) { return 'NO_USERS'; } @@ -3096,7 +3096,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna } $db->sql_freeresult($result); - if (!sizeof($user_id_ary)) + if (!count($user_id_ary)) { return false; } @@ -3137,7 +3137,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna $db->sql_freeresult($result); $result = user_get_id_name($user_id_ary, $username_ary); - if (!sizeof($user_id_ary) || $result !== false) + if (!count($user_id_ary) || $result !== false) { return 'NO_USERS'; } @@ -3500,7 +3500,7 @@ function group_update_listings($group_id) $hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_')); - if (!sizeof($hold_ary)) + if (empty($hold_ary)) { return; } diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php index 214c5590e7..5851469806 100644 --- a/phpBB/phpbb/db/driver/driver.php +++ b/phpBB/phpbb/db/driver/driver.php @@ -537,7 +537,9 @@ abstract class driver implements driver_interface */ function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) { - if (!sizeof($array)) + $array = (array) $array; + + if (!count($array)) { if (!$allow_empty_set) { @@ -559,12 +561,7 @@ abstract class driver implements driver_interface } } - if (!is_array($array)) - { - $array = array($array); - } - - if (sizeof($array) == 1) + if (count($array) == 1) { @reset($array); $var = current($array); @@ -632,7 +629,7 @@ abstract class driver implements driver_interface */ function sql_multi_insert($table, $sql_ary) { - if (!sizeof($sql_ary)) + if (!count($sql_ary)) { return false; } @@ -738,7 +735,7 @@ abstract class driver implements driver_interface // We run the following code to determine if we need to re-order the table array. ;) // The reason for this is that for multi-aliased tables (two equal tables) in the FROM statement the last table need to match the first comparison. // DBMS who rely on this: Oracle, PostgreSQL and MSSQL. For all other DBMS it makes absolutely no difference in which order the table is. - if (!empty($array['LEFT_JOIN']) && sizeof($array['FROM']) > 1 && $used_multi_alias !== false) + if (!empty($array['LEFT_JOIN']) && count($array['FROM']) > 1 && $used_multi_alias !== false) { // Take first LEFT JOIN $join = current($array['LEFT_JOIN']); @@ -848,7 +845,7 @@ abstract class driver implements driver_interface default: - switch (sizeof($condition)) + switch (count($condition)) { case 3: @@ -1138,7 +1135,7 @@ abstract class driver implements driver_interface $html_table = func_get_arg(2); $row = func_get_arg(3); - if (!$html_table && sizeof($row)) + if (!$html_table && count($row)) { $html_table = true; $this->html_hold .= '