1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/14972] replace all occurrences of sizeof() with the count()

PHPBB3-14972
This commit is contained in:
rxu
2017-06-28 00:58:03 +07:00
committed by Marc Alexander
parent ff18802656
commit f8fbe37936
165 changed files with 983 additions and 983 deletions

View File

@@ -267,7 +267,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
unset($row['line2'], $row['line3']);
}
}
return (sizeof($row)) ? $row : false;
return (count($row)) ? $row : false;
}
/**

View File

@@ -136,7 +136,7 @@ class oracle extends \phpbb\db\driver\driver
*/
function _rewrite_col_compare($args)
{
if (sizeof($args) == 4)
if (count($args) == 4)
{
if ($args[2] == '=')
{
@@ -290,7 +290,7 @@ class oracle extends \phpbb\db\driver\driver
and/or need the db restore script, uncomment this.
if (sizeof($cols) !== sizeof($vals))
if (count($cols) !== count($vals))
{
// Try to replace some common data we know is from our restore script or from other sources
$regs[3] = str_replace("'||chr(47)||'", '/', $regs[3]);
@@ -332,7 +332,7 @@ class oracle extends \phpbb\db\driver\driver
if ($string)
{
// New value if cols != value
$vals[(sizeof($cols) !== sizeof($vals)) ? $i : $i - 1] .= $string;
$vals[(count($cols) !== count($vals)) ? $i : $i - 1] .= $string;
}
$vals = array(0 => $vals);

View File

@@ -132,14 +132,14 @@ class mssql_extractor extends base_extractor
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
if (!sizeof($rows))
if (!count($rows))
{
$sql_data .= "ALTER TABLE [$table_name] WITH NOCHECK ADD\n";
$sql_data .= "\tCONSTRAINT [{$row['CONSTRAINT_NAME']}] PRIMARY KEY CLUSTERED \n\t(\n";
}
$rows[] = "\t\t[{$row['COLUMN_NAME']}]";
}
if (sizeof($rows))
if (count($rows))
{
$sql_data .= implode(",\n", $rows);
$sql_data .= "\n\t) ON [PRIMARY] \nGO\n";

View File

@@ -82,7 +82,7 @@ class oracle_extractor extends base_extractor
}
$this->db->sql_freeresult($result);
if (sizeof($primary_key))
if (count($primary_key))
{
$rows[] = " CONSTRAINT {$constraint_name} PRIMARY KEY (" . implode(', ', $primary_key) . ')';
}
@@ -103,7 +103,7 @@ class oracle_extractor extends base_extractor
}
$this->db->sql_freeresult($result);
if (sizeof($unique))
if (count($unique))
{
$rows[] = " CONSTRAINT {$constraint_name} UNIQUE (" . implode(', ', $unique) . ')';
}

View File

@@ -133,7 +133,7 @@ class style_update_p1 extends \phpbb\db\migration\migration
}
// Remove old entries from styles table
if (!sizeof($valid_styles))
if (!count($valid_styles))
{
// No valid styles: remove everything and add prosilver
$this->sql_query('DELETE FROM ' . STYLES_TABLE);

View File

@@ -93,13 +93,13 @@ class teampage extends \phpbb\db\migration\migration
$teampage_entries[] = array(
'group_id' => (int) $row['group_id'],
'teampage_name' => '',
'teampage_position' => sizeof($teampage_entries) + 1,
'teampage_position' => count($teampage_entries) + 1,
'teampage_parent' => 0,
);
}
$this->db->sql_freeresult($result);
if (sizeof($teampage_entries))
if (count($teampage_entries))
{
$this->db->sql_multi_insert(TEAMPAGE_TABLE, $teampage_entries);
}

View File

@@ -134,7 +134,7 @@ class config implements \phpbb\db\migration\tool\tool_interface
case 'remove':
$call = 'add';
if (sizeof($arguments) == 1)
if (count($arguments) == 1)
{
$arguments[] = '';
}

View File

@@ -110,7 +110,7 @@ class config_text implements \phpbb\db\migration\tool\tool_interface
case 'remove':
$call = 'add';
if (sizeof($arguments) == 1)
if (count($arguments) == 1)
{
$arguments[] = '';
}

View File

@@ -515,7 +515,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
$parent_id = $parent_id ?: 0;
// If automatic adding is in action, convert array back to string to simplify things
if (is_array($data) && sizeof($data) == 1)
if (is_array($data) && count($data) == 1)
{
$data = $data['module_langname'];
}
@@ -528,7 +528,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
// Search for the parent module_langname
$ids = array_keys($this->module_categories, $parent_id);
switch (sizeof($ids))
switch (count($ids))
{
// No parent with the given module_langname exist
case 0:

View File

@@ -442,7 +442,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
}
);
if (sizeof($auth_option))
if (count($auth_option))
{
return $this->permission_set($role_name, $auth_option, 'role', $has_permission);
}

View File

@@ -632,7 +632,7 @@ class migrator
*/
protected function process_data_step($steps, $state, $revert = false)
{
if (sizeof($steps) === 0)
if (count($steps) === 0)
{
return true;
}
@@ -659,7 +659,7 @@ class migrator
// Result will be null or true if everything completed correctly
// Stop after each update step, to let the updater control the script runtime
$result = $this->run_step($steps[$step], $last_result, $revert);
if (($result !== null && $result !== true) || $step + 1 < sizeof($steps))
if (($result !== null && $result !== true) || $step + 1 < count($steps))
{
return array(
'result' => $result,

View File

@@ -92,7 +92,7 @@ class sql_insert_buffer
// Flush buffer if it is full or when DB does not support multi inserts.
// In the later case, the buffer will always only contain one row.
if (!$this->db->get_multi_insert() || sizeof($this->buffer) >= $this->max_buffered_rows)
if (!$this->db->get_multi_insert() || count($this->buffer) >= $this->max_buffered_rows)
{
return $this->flush();
}
@@ -104,7 +104,7 @@ class sql_insert_buffer
* Inserts a row set, i.e. an array of rows, by calling insert().
*
* Please note that it is in most cases better to use insert() instead of
* first building a huge rowset. Or at least sizeof($rows) should be kept
* first building a huge rowset. Or at least count($rows) should be kept
* small.
*
* @param array $rows

View File

@@ -440,7 +440,7 @@ class mssql extends tools
{
$result = $this->sql_index_drop($table_name, $index_name);
$statements = array_merge($statements, $result);
if (sizeof($index_data) > 1)
if (count($index_data) > 1)
{
// Remove this column from the index and recreate it
$recreate_indexes[$index_name] = array_diff($index_data, array($column_name));