mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-05 00:07:44 +02:00
[ticket/14972] Fix sizeof calls
As of PHP 7.2, only arrays and objects implementing the Countable interface should be passed as a count() or sizeof() parameter. See https://github.com/php/php-src/blob/php-7.2.0alpha2/UPGRADING#L197-L198 Also, sizeof() seems to be sheduled for deprecation, see https://wiki.php.net/rfc/deprecations_php_7_2#suggested_deprecations PHPBB3-14972
This commit is contained in:
@@ -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 .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
|
||||
@@ -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');
|
||||
|
||||
|
Reference in New Issue
Block a user