aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorDerky <derky@phpbb.com>2018-01-05 22:44:34 +0100
committerDerky <derky@phpbb.com>2018-01-05 22:44:34 +0100
commit182a96f2738316adcb292816a9ac8af0e0cb5866 (patch)
tree0b6a0fb40a2ea201fdf4cfc5e4cc5ebfb4cb46db /phpBB
parent2fcb8ab87fb30c57b106695859c2661fc3cc2837 (diff)
parent98c50695003652fba171e25dd2e171ddffbd72e1 (diff)
downloadforums-182a96f2738316adcb292816a9ac8af0e0cb5866.tar
forums-182a96f2738316adcb292816a9ac8af0e0cb5866.tar.gz
forums-182a96f2738316adcb292816a9ac8af0e0cb5866.tar.bz2
forums-182a96f2738316adcb292816a9ac8af0e0cb5866.tar.xz
forums-182a96f2738316adcb292816a9ac8af0e0cb5866.zip
Merge pull request #4680 from marc1706/ticket/15055
[ticket/15055] Add appveyor file to allow running tests on appveyor as well
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/acp/acp_bbcodes.php2
-rw-r--r--phpBB/phpbb/db/driver/mssqlnative.php3
-rw-r--r--phpBB/phpbb/db/tools/mssql.php84
-rw-r--r--phpBB/phpbb/db/tools/tools.php15
-rw-r--r--phpBB/phpbb/tree/nestedset.php2
5 files changed, 83 insertions, 23 deletions
diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php
index 7153a8ec70..2634ae1874 100644
--- a/phpBB/includes/acp/acp_bbcodes.php
+++ b/phpBB/includes/acp/acp_bbcodes.php
@@ -253,7 +253,7 @@ class acp_bbcodes
if ($row)
{
- $bbcode_id = $row['max_bbcode_id'] + 1;
+ $bbcode_id = (int) $row['max_bbcode_id'] + 1;
// Make sure it is greater than the core bbcode ids...
if ($bbcode_id <= NUM_CORE_BBCODES)
diff --git a/phpBB/phpbb/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php
index 2859945915..de81a6a0c8 100644
--- a/phpBB/phpbb/db/driver/mssqlnative.php
+++ b/phpBB/phpbb/db/driver/mssqlnative.php
@@ -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('');
diff --git a/phpBB/phpbb/db/tools/mssql.php b/phpBB/phpbb/db/tools/mssql.php
index 8b95b7070e..cbedf9a5c4 100644
--- a/phpBB/phpbb/db/tools/mssql.php
+++ b/phpBB/phpbb/db/tools/mssql.php
@@ -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)',
),
);
@@ -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);
@@ -555,6 +556,21 @@ class mssql extends tools
}
/**
+ * {@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}
*/
function sql_list_index($table_name)
@@ -685,6 +701,38 @@ class mssql extends tools
}
/**
+ * 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
*
* Identity columns cannot have defaults set for them.
diff --git a/phpBB/phpbb/db/tools/tools.php b/phpBB/phpbb/db/tools/tools.php
index 2f891e43d5..d21d34b8a9 100644
--- a/phpBB/phpbb/db/tools/tools.php
+++ b/phpBB/phpbb/db/tools/tools.php
@@ -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,7 +1583,7 @@ 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);
}
}
@@ -1590,6 +1591,16 @@ class tools implements tools_interface
}
/**
+ * 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}
*/
function sql_list_index($table_name)
diff --git a/phpBB/phpbb/tree/nestedset.php b/phpBB/phpbb/tree/nestedset.php
index c02deaebf4..eadd2b3273 100644
--- a/phpBB/phpbb/tree/nestedset.php
+++ b/phpBB/phpbb/tree/nestedset.php
@@ -533,7 +533,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- $diff = ' + ' . ($row[$this->column_right_id] - (int) $item[$this->column_left_id] + 1);
+ $diff = ' + ' . ((int) $row[$this->column_right_id] - (int) $item[$this->column_left_id] + 1);
}
$sql = 'UPDATE ' . $this->table_name . '