aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_admin.php
diff options
context:
space:
mode:
authorrxu <rxu@mail.ru>2017-01-09 00:23:08 +0700
committerMarc Alexander <admin@m-a-styles.de>2018-01-01 13:08:12 +0100
commit8c3808e9e7db09531154b2520cbfcc7529a5c752 (patch)
treeca5edd56088f7c689fcd1afe42a51baa66768508 /phpBB/includes/functions_admin.php
parent0ff5f9fa0edf9ac3125cc4e871609a90cee1cfac (diff)
downloadforums-8c3808e9e7db09531154b2520cbfcc7529a5c752.tar
forums-8c3808e9e7db09531154b2520cbfcc7529a5c752.tar.gz
forums-8c3808e9e7db09531154b2520cbfcc7529a5c752.tar.bz2
forums-8c3808e9e7db09531154b2520cbfcc7529a5c752.tar.xz
forums-8c3808e9e7db09531154b2520cbfcc7529a5c752.zip
[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
Diffstat (limited to 'phpBB/includes/functions_admin.php')
-rw-r--r--phpBB/includes/functions_admin.php92
1 files changed, 46 insertions, 46 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 96916e1e43..e2cab6d4a9 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 .= '<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);
}
/**
@@ -1232,7 +1232,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)
{
@@ -1363,7 +1363,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;
@@ -1377,7 +1377,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
else
{
- if (!sizeof($where_ids))
+ if (!count($where_ids))
{
return;
}
@@ -1416,7 +1416,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;
}
@@ -1533,7 +1533,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
@@ -1579,7 +1579,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
@@ -1638,7 +1638,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
@@ -1684,7 +1684,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
@@ -1736,7 +1736,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
$db->sql_freeresult($result);
- if (!sizeof($forum_ids))
+ if (!count($forum_ids))
{
break;
}
@@ -1775,7 +1775,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
@@ -1795,7 +1795,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'];
@@ -1805,7 +1805,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
@@ -1825,7 +1825,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'];
@@ -1834,7 +1834,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
@@ -1902,7 +1902,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) . '
@@ -2025,20 +2025,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)
@@ -2081,7 +2081,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();
@@ -2098,7 +2098,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);
}
@@ -2121,7 +2121,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
@@ -2174,7 +2174,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)
{
@@ -2239,7 +2239,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) . '
@@ -2256,7 +2256,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);
}
@@ -2278,7 +2278,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;
}
@@ -2451,7 +2451,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);
@@ -2496,7 +2496,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
@@ -2536,7 +2536,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);
@@ -2640,7 +2640,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) . '
@@ -2650,7 +2650,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(
@@ -2684,7 +2684,7 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false)
}
$db->sql_freeresult($result);
- if (!sizeof($groups))
+ if (!count($groups))
{
return;
}
@@ -2714,7 +2714,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) . '
@@ -2737,7 +2737,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)) . '
@@ -3000,7 +3000,7 @@ function tidy_warnings()
}
$db->sql_freeresult($result);
- if (sizeof($warning_list))
+ if (count($warning_list))
{
$db->sql_transaction('begin');