From f8fbe3793680af1dae2db2829cfc84068831c52f Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 28 Jun 2017 00:58:03 +0700 Subject: [ticket/14972] replace all occurrences of sizeof() with the count() PHPBB3-14972 --- phpBB/includes/functions_convert.php | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'phpBB/includes/functions_convert.php') diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 176e3dd6de..4a8f664fe9 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -192,7 +192,7 @@ function get_group_id($group_name) $db->sql_freeresult($result); } - if (!sizeof($group_mapping)) + if (!count($group_mapping)) { add_default_groups(); return get_group_id($group_name); @@ -307,7 +307,7 @@ function decode_ip($int_ip) $hexipbang = explode('.', chunk_split($int_ip, 2, '.')); // Any mod changing the way ips are stored? Then we are not able to convert and enter the ip "as is" to not "destroy" anything... - if (sizeof($hexipbang) < 4) + if (count($hexipbang) < 4) { return $int_ip; } @@ -479,7 +479,7 @@ function import_avatar_gallery($gallery_name = '', $subdirs_as_galleries = false $dir->close(); } - for ($i = 0, $end = sizeof($dirlist); $i < $end; ++$i) + for ($i = 0, $end = count($dirlist); $i < $end; ++$i) { $dir = $dirlist[$i]; @@ -1261,7 +1261,7 @@ function get_config() } } - if (!sizeof($convert_config)) + if (!count($convert_config)) { $convert->p_master->error($user->lang['CONV_ERROR_CONFIG_EMPTY'], __LINE__, __FILE__); } @@ -1406,9 +1406,9 @@ function get_path($src_path, $src_url, $test_file) $url_parts = explode('/', $m[2]); if (substr($src_url, -1) != '/') { - if (preg_match('/.*\.([a-z0-9]{3,4})$/i', $url_parts[sizeof($url_parts) - 1])) + if (preg_match('/.*\.([a-z0-9]{3,4})$/i', $url_parts[count($url_parts) - 1])) { - $url_parts[sizeof($url_parts) - 1] = ''; + $url_parts[count($url_parts) - 1] = ''; } else { @@ -1425,9 +1425,9 @@ function get_path($src_path, $src_url, $test_file) $path_array = array(); $phpbb_parts = explode('/', $script_path); - for ($i = 0, $end = sizeof($url_parts); $i < $end; ++$i) + for ($i = 0, $end = count($url_parts); $i < $end; ++$i) { - if ($i < sizeof($phpbb_parts[$i]) && $url_parts[$i] == $phpbb_parts[$i]) + if ($i < count($phpbb_parts[$i]) && $url_parts[$i] == $phpbb_parts[$i]) { $path_array[] = $url_parts[$i]; unset($url_parts[$i]); @@ -1435,7 +1435,7 @@ function get_path($src_path, $src_url, $test_file) else { $path = ''; - for ($j = $i, $end2 = sizeof($phpbb_parts); $j < $end2; ++$j) + for ($j = $i, $end2 = count($phpbb_parts); $j < $end2; ++$j) { $path .= '../'; } @@ -1458,7 +1458,7 @@ function get_path($src_path, $src_url, $test_file) function compare_table($tables, $tablename, &$prefixes) { - for ($i = 0, $table_size = sizeof($tables); $i < $table_size; ++$i) + for ($i = 0, $table_size = count($tables); $i < $table_size; ++$i) { if (preg_match('/(.*)' . $tables[$i] . '$/', $tablename, $m)) { @@ -1754,7 +1754,7 @@ function add_default_groups() ); } - if (sizeof($sql_ary)) + if (count($sql_ary)) { $db->sql_multi_insert(GROUPS_TABLE, $sql_ary); } @@ -1786,7 +1786,7 @@ function add_groups_to_teampage() } $db->sql_freeresult($result); - if (sizeof($teampage_ary)) + if (count($teampage_ary)) { $db->sql_multi_insert(TEAMPAGE_TABLE, $teampage_ary); } @@ -2101,7 +2101,7 @@ function update_topics_posted() } unset($posted); - if (sizeof($sql_ary)) + if (count($sql_ary)) { $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary); } @@ -2136,7 +2136,7 @@ function fix_empty_primary_groups() } $db->sql_freeresult($result); - if (sizeof($user_ids)) + if (count($user_ids)) { $db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('administrators') . ' WHERE group_id = 0 AND ' . $db->sql_in_set('user_id', $user_ids)); @@ -2152,7 +2152,7 @@ function fix_empty_primary_groups() } $db->sql_freeresult($result); - if (sizeof($user_ids)) + if (count($user_ids)) { $db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('global_moderators') . ' WHERE group_id = 0 AND ' . $db->sql_in_set('user_id', $user_ids)); @@ -2264,7 +2264,7 @@ function convert_bbcode($message, $convert_size = true, $extended_bbcodes = fals "\n\n" ); - for ($i = 0, $end = sizeof($str_from); $i < $end; ++$i) + for ($i = 0, $end = count($str_from); $i < $end; ++$i) { $origx[] = '#\\' . str_replace(']', '\\]', $str_from[$i]) . '#is'; $replx[] = $str_to[$i]; @@ -2273,7 +2273,7 @@ function convert_bbcode($message, $convert_size = true, $extended_bbcodes = fals if (preg_match_all('#\[email=([^\]]+)\](.*?)\[/email\]#i', $message, $m)) { - for ($i = 0, $end = sizeof($m[1]); $i < $end; ++$i) + for ($i = 0, $end = count($m[1]); $i < $end; ++$i) { if ($m[1][$i] == $m[2][$i]) { @@ -2292,7 +2292,7 @@ function convert_bbcode($message, $convert_size = true, $extended_bbcodes = fals $message = preg_replace('#\[size=([0-9]+)\](.*?)\[/size\]#i', '[size=\1]\2[/size]', $message); $message = preg_replace('#\[size=[0-9]{2,}\](.*?)\[/size\]#i', '[size=29]\1[/size]', $message); - for ($i = sizeof($size); $i;) + for ($i = count($size); $i;) { $i--; $message = str_replace('[size=' . $i . ']', '[size=' . $size[$i] . ']', $message); @@ -2335,9 +2335,9 @@ function copy_file($src, $trg, $overwrite = false, $die_on_failure = true, $sour $path = $phpbb_root_path; $parts = explode('/', $trg); - unset($parts[sizeof($parts) - 1]); + unset($parts[count($parts) - 1]); - for ($i = 0, $end = sizeof($parts); $i < $end; ++$i) + for ($i = 0, $end = count($parts); $i < $end; ++$i) { $path .= $parts[$i] . '/'; @@ -2437,7 +2437,7 @@ function copy_dir($src, $trg, $copy_subdirs = true, $overwrite = false, $die_on_ if ($copy_subdirs) { - for ($i = 0, $end = sizeof($dirlist); $i < $end; ++$i) + for ($i = 0, $end = count($dirlist); $i < $end; ++$i) { $dir = $dirlist[$i]; @@ -2458,21 +2458,21 @@ function copy_dir($src, $trg, $copy_subdirs = true, $overwrite = false, $die_on_ $bad_dirs[] = $trg_path . $dir; } - if (!sizeof($bad_dirs)) + if (!count($bad_dirs)) { copy_dir($src . $dir, $trg . $dir, true, $overwrite, $die_on_failure, $source_relative_path); } } } - if (sizeof($bad_dirs)) + if (count($bad_dirs)) { - $str = (sizeof($bad_dirs) == 1) ? $user->lang['MAKE_FOLDER_WRITABLE'] : $user->lang['MAKE_FOLDERS_WRITABLE']; + $str = (count($bad_dirs) == 1) ? $user->lang['MAKE_FOLDER_WRITABLE'] : $user->lang['MAKE_FOLDERS_WRITABLE']; sort($bad_dirs); $convert->p_master->error(sprintf($str, implode('
', $bad_dirs)), __LINE__, __FILE__); } - for ($i = 0, $end = sizeof($filelist); $i < $end; ++$i) + for ($i = 0, $end = count($filelist); $i < $end; ++$i) { copy_file($src . $filelist[$i], $trg . $filelist[$i], $overwrite, $die_on_failure, $source_relative_path); } -- cgit v1.2.1