mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-05 08:17:47 +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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user