mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
Merge remote-tracking branch 'upstream/3.2.x' into prep-release-3.2.2
This commit is contained in:
@@ -537,7 +537,9 @@ abstract class driver implements driver_interface
|
||||
*/
|
||||
function sql_in_set($field, $array, $negate = false, $allow_empty_set = false)
|
||||
{
|
||||
if (!sizeof($array))
|
||||
$array = (array) $array;
|
||||
|
||||
if (!count($array))
|
||||
{
|
||||
if (!$allow_empty_set)
|
||||
{
|
||||
@@ -559,12 +561,7 @@ abstract class driver implements driver_interface
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($array))
|
||||
{
|
||||
$array = array($array);
|
||||
}
|
||||
|
||||
if (sizeof($array) == 1)
|
||||
if (count($array) == 1)
|
||||
{
|
||||
@reset($array);
|
||||
$var = current($array);
|
||||
@@ -632,7 +629,7 @@ abstract class driver implements driver_interface
|
||||
*/
|
||||
function sql_multi_insert($table, $sql_ary)
|
||||
{
|
||||
if (!sizeof($sql_ary))
|
||||
if (!count($sql_ary))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -738,7 +735,7 @@ abstract class driver implements driver_interface
|
||||
// We run the following code to determine if we need to re-order the table array. ;)
|
||||
// The reason for this is that for multi-aliased tables (two equal tables) in the FROM statement the last table need to match the first comparison.
|
||||
// DBMS who rely on this: Oracle, PostgreSQL and MSSQL. For all other DBMS it makes absolutely no difference in which order the table is.
|
||||
if (!empty($array['LEFT_JOIN']) && sizeof($array['FROM']) > 1 && $used_multi_alias !== false)
|
||||
if (!empty($array['LEFT_JOIN']) && count($array['FROM']) > 1 && $used_multi_alias !== false)
|
||||
{
|
||||
// Take first LEFT JOIN
|
||||
$join = current($array['LEFT_JOIN']);
|
||||
@@ -848,7 +845,7 @@ abstract class driver implements driver_interface
|
||||
|
||||
default:
|
||||
|
||||
switch (sizeof($condition))
|
||||
switch (count($condition))
|
||||
{
|
||||
case 3:
|
||||
|
||||
@@ -1138,7 +1135,7 @@ abstract class driver implements driver_interface
|
||||
$html_table = func_get_arg(2);
|
||||
$row = func_get_arg(3);
|
||||
|
||||
if (!$html_table && sizeof($row))
|
||||
if (!$html_table && count($row))
|
||||
{
|
||||
$html_table = true;
|
||||
$this->html_hold .= '<table cellspacing="1"><tr>';
|
||||
|
@@ -50,7 +50,8 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
||||
$this->db_connect_id = sqlsrv_connect($this->server, array(
|
||||
'Database' => $this->dbname,
|
||||
'UID' => $this->user,
|
||||
'PWD' => $sqlpassword
|
||||
'PWD' => $sqlpassword,
|
||||
'CharacterSet' => 'UTF-8'
|
||||
));
|
||||
|
||||
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
|
||||
@@ -267,7 +268,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
||||
unset($row['line2'], $row['line3']);
|
||||
}
|
||||
}
|
||||
return (sizeof($row)) ? $row : false;
|
||||
return (count($row)) ? $row : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
|
@@ -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";
|
||||
|
@@ -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) . ')';
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -15,10 +15,17 @@ namespace phpbb\db\migration\data\v320;
|
||||
|
||||
class remove_outdated_media extends \phpbb\db\migration\migration
|
||||
{
|
||||
// Following constants were deprecated in 3.2
|
||||
// and moved from constants.php to compatibility_globals.php,
|
||||
// thus define them as class constants
|
||||
const ATTACHMENT_CATEGORY_WM = 2;
|
||||
const ATTACHMENT_CATEGORY_RM = 3;
|
||||
const ATTACHMENT_CATEGORY_QUICKTIME = 6;
|
||||
|
||||
protected $cat_id = array(
|
||||
ATTACHMENT_CATEGORY_WM,
|
||||
ATTACHMENT_CATEGORY_RM,
|
||||
ATTACHMENT_CATEGORY_QUICKTIME,
|
||||
self::ATTACHMENT_CATEGORY_WM,
|
||||
self::ATTACHMENT_CATEGORY_RM,
|
||||
self::ATTACHMENT_CATEGORY_QUICKTIME,
|
||||
);
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -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[] = '';
|
||||
}
|
||||
|
@@ -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[] = '';
|
||||
}
|
||||
|
@@ -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:
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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,
|
||||
|
@@ -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
|
||||
|
@@ -49,18 +49,18 @@ class mssql extends tools
|
||||
'STEXT' => '[varchar] (3000)',
|
||||
'TEXT' => '[varchar] (8000)',
|
||||
'MTEXT' => '[text]',
|
||||
'XSTEXT_UNI'=> '[varchar] (100)',
|
||||
'STEXT_UNI' => '[varchar] (255)',
|
||||
'TEXT_UNI' => '[varchar] (4000)',
|
||||
'MTEXT_UNI' => '[text]',
|
||||
'XSTEXT_UNI'=> '[nvarchar] (100)',
|
||||
'STEXT_UNI' => '[nvarchar] (255)',
|
||||
'TEXT_UNI' => '[nvarchar] (4000)',
|
||||
'MTEXT_UNI' => '[ntext]',
|
||||
'TIMESTAMP' => '[int]',
|
||||
'DECIMAL' => '[float]',
|
||||
'DECIMAL:' => '[float]',
|
||||
'PDECIMAL' => '[float]',
|
||||
'PDECIMAL:' => '[float]',
|
||||
'VCHAR_UNI' => '[varchar] (255)',
|
||||
'VCHAR_UNI:'=> '[varchar] (%d)',
|
||||
'VCHAR_CI' => '[varchar] (255)',
|
||||
'VCHAR_UNI' => '[nvarchar] (255)',
|
||||
'VCHAR_UNI:'=> '[nvarchar] (%d)',
|
||||
'VCHAR_CI' => '[nvarchar] (255)',
|
||||
'VARBINARY' => '[varchar] (255)',
|
||||
),
|
||||
|
||||
@@ -80,18 +80,18 @@ class mssql extends tools
|
||||
'STEXT' => '[varchar] (3000)',
|
||||
'TEXT' => '[varchar] (8000)',
|
||||
'MTEXT' => '[text]',
|
||||
'XSTEXT_UNI'=> '[varchar] (100)',
|
||||
'STEXT_UNI' => '[varchar] (255)',
|
||||
'TEXT_UNI' => '[varchar] (4000)',
|
||||
'MTEXT_UNI' => '[text]',
|
||||
'XSTEXT_UNI'=> '[nvarchar] (100)',
|
||||
'STEXT_UNI' => '[nvarchar] (255)',
|
||||
'TEXT_UNI' => '[nvarchar] (4000)',
|
||||
'MTEXT_UNI' => '[ntext]',
|
||||
'TIMESTAMP' => '[int]',
|
||||
'DECIMAL' => '[float]',
|
||||
'DECIMAL:' => '[float]',
|
||||
'PDECIMAL' => '[float]',
|
||||
'PDECIMAL:' => '[float]',
|
||||
'VCHAR_UNI' => '[varchar] (255)',
|
||||
'VCHAR_UNI:'=> '[varchar] (%d)',
|
||||
'VCHAR_CI' => '[varchar] (255)',
|
||||
'VCHAR_UNI' => '[nvarchar] (255)',
|
||||
'VCHAR_UNI:'=> '[nvarchar] (%d)',
|
||||
'VCHAR_CI' => '[nvarchar] (255)',
|
||||
'VARBINARY' => '[varchar] (255)',
|
||||
),
|
||||
);
|
||||
@@ -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));
|
||||
@@ -448,6 +448,10 @@ class mssql extends tools
|
||||
}
|
||||
}
|
||||
|
||||
// Drop primary keys depending on this column
|
||||
$result = $this->mssql_get_drop_default_primary_key_queries($table_name, $column_name);
|
||||
$statements = array_merge($statements, $result);
|
||||
|
||||
// Drop default value constraint
|
||||
$result = $this->mssql_get_drop_default_constraints_queries($table_name, $column_name);
|
||||
$statements = array_merge($statements, $result);
|
||||
@@ -541,10 +545,7 @@ class mssql extends tools
|
||||
{
|
||||
$statements = array();
|
||||
|
||||
if ($this->mssql_is_sql_server_2000())
|
||||
{
|
||||
$this->check_index_name_length($table_name, $index_name);
|
||||
}
|
||||
$this->check_index_name_length($table_name, $index_name);
|
||||
|
||||
// remove index length
|
||||
$column = preg_replace('#:.*$#', '', $column);
|
||||
@@ -554,6 +555,21 @@ class mssql extends tools
|
||||
return $this->_sql_run_sql($statements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function get_max_index_name_length()
|
||||
{
|
||||
if ($this->mssql_is_sql_server_2000())
|
||||
{
|
||||
return parent::get_max_index_name_length();
|
||||
}
|
||||
else
|
||||
{
|
||||
return 128;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -684,6 +700,38 @@ class mssql extends tools
|
||||
return $statements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get queries to drop the primary keys depending on the specified column
|
||||
*
|
||||
* We need to drop primary keys depending on this column before being able
|
||||
* to delete them.
|
||||
*
|
||||
* @param string $table_name
|
||||
* @param string $column_name
|
||||
* @return array Array with SQL statements
|
||||
*/
|
||||
protected function mssql_get_drop_default_primary_key_queries($table_name, $column_name)
|
||||
{
|
||||
$statements = array();
|
||||
|
||||
$sql = "SELECT ccu.CONSTRAINT_NAME, ccu.COLUMN_NAME
|
||||
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
|
||||
JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ON tc.CONSTRAINT_NAME = ccu.Constraint_name
|
||||
WHERE tc.TABLE_NAME = '{$table_name}'
|
||||
AND tc.CONSTRAINT_TYPE = 'Primary Key'
|
||||
AND ccu.COLUMN_NAME = '{$column_name}'";
|
||||
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
while ($primary_key = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $primary_key['CONSTRAINT_NAME'] . ']';
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return $statements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if column is an identity column
|
||||
*
|
||||
|
@@ -1561,7 +1561,8 @@ class tools implements tools_interface
|
||||
*/
|
||||
protected function check_index_name_length($table_name, $index_name, $throw_error = true)
|
||||
{
|
||||
if (strlen($index_name) > 30)
|
||||
$max_index_name_length = $this->get_max_index_name_length();
|
||||
if (strlen($index_name) > $max_index_name_length)
|
||||
{
|
||||
// Try removing the table prefix if it's at the beginning
|
||||
$table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config)
|
||||
@@ -1582,13 +1583,23 @@ class tools implements tools_interface
|
||||
|
||||
if ($throw_error)
|
||||
{
|
||||
trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR);
|
||||
trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is $max_index_name_length characters.", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return $index_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get maximum index name length. Might vary depending on db type
|
||||
*
|
||||
* @return int Maximum index name length
|
||||
*/
|
||||
protected function get_max_index_name_length()
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user