aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/db/tools/mssql.php46
-rw-r--r--phpBB/phpbb/install/module/update_filesystem/task/diff_files.php71
2 files changed, 88 insertions, 29 deletions
diff --git a/phpBB/phpbb/db/tools/mssql.php b/phpBB/phpbb/db/tools/mssql.php
index a132832005..d31aa2ba0b 100644
--- a/phpBB/phpbb/db/tools/mssql.php
+++ b/phpBB/phpbb/db/tools/mssql.php
@@ -477,7 +477,7 @@ class mssql extends tools
{
$statements = array();
- $statements[] = 'DROP INDEX ' . $table_name . '.' . $index_name;
+ $statements[] = 'DROP INDEX [' . $table_name . '].[' . $index_name . ']';
return $this->_sql_run_sql($statements);
}
@@ -524,7 +524,10 @@ class mssql extends tools
{
$statements = array();
- $this->check_index_name_length($table_name, $index_name);
+ if ($this->is_sql_server_2000())
+ {
+ $this->check_index_name_length($table_name, $index_name);
+ }
$statements[] = 'CREATE UNIQUE INDEX [' . $index_name . '] ON [' . $table_name . ']([' . implode('], [', $column) . '])';
@@ -538,7 +541,10 @@ class mssql extends tools
{
$statements = array();
- $this->check_index_name_length($table_name, $index_name);
+ if ($this->is_sql_server_2000())
+ {
+ $this->check_index_name_length($table_name, $index_name);
+ }
// remove index length
$column = preg_replace('#:.*$#', '', $column);
@@ -601,7 +607,7 @@ class mssql extends tools
// Change the column
$statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql'];
- if (!empty($column_data['default']))
+ if (!empty($column_data['default']) && !$this->mssql_is_column_identity($table_name, $column_name))
{
// Add new default value constraint
$statements[] = 'ALTER TABLE [' . $table_name . '] ADD CONSTRAINT [DF_' . $table_name . '_' . $column_name . '_1] ' . $column_data['default'] . ' FOR [' . $column_name . ']';
@@ -679,6 +685,37 @@ class mssql extends tools
}
/**
+ * Checks to see if column is an identity column
+ *
+ * Identity columns cannot have defaults set for them.
+ *
+ * @param string $table_name
+ * @param string $column_name
+ * @return bool true if identity, false if not
+ */
+ protected function mssql_is_column_identity($table_name, $column_name)
+ {
+ if ($this->mssql_is_sql_server_2000())
+ {
+ // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx
+ // Deprecated in SQL Server 2005
+ $sql = "SELECT COLUMNPROPERTY(object_id('{$table_name}'), '{$column_name}', 'IsIdentity') AS is_identity";
+ }
+ else
+ {
+ $sql = "SELECT is_identity FROM sys.columns
+ WHERE object_id = object_id('{$table_name}')
+ AND name = '{$column_name}'";
+ }
+
+ $result = $this->db->sql_query($sql);
+ $is_identity = $this->db->sql_fetchfield('is_identity');
+ $this->db->sql_freeresult($result);
+
+ return (bool) $is_identity;
+ }
+
+ /**
* Get a list with existing indexes for the column
*
* @param string $table_name
@@ -717,6 +754,7 @@ class mssql extends tools
AND cols.object_id = ix.object_id
WHERE ix.object_id = object_id('{$table_name}')
AND cols.name = '{$column_name}'
+ AND ix.is_primary_key = 0
AND ix.is_unique = " . ($unique ? '1' : '0');
}
diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php
index e3e6db6263..1792a3b723 100644
--- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php
+++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php
@@ -132,41 +132,62 @@ class diff_files extends task_base
$file_contents = array();
// Handle the special case when user created a file with the filename that is now new in the core
- $file_contents[0] = (file_exists($old_path . $filename)) ? file_get_contents($old_path . $filename) : '';
+ if (file_exists($old_path . $filename))
+ {
+ $file_contents[0] = file_get_contents($old_path . $filename);
- $filenames = array(
- $this->phpbb_root_path . $filename,
- $new_path . $filename
- );
+ $filenames = array(
+ $this->phpbb_root_path . $filename,
+ $new_path . $filename
+ );
- foreach ($filenames as $file_to_diff)
- {
- $file_contents[] = file_get_contents($file_to_diff);
+ foreach ($filenames as $file_to_diff)
+ {
+ $file_contents[] = file_get_contents($file_to_diff);
+
+ if ($file_contents[sizeof($file_contents) - 1] === false)
+ {
+ $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff));
+ unset($file_contents);
+ throw new user_interaction_required_exception();
+ }
+ }
- if ($file_contents[sizeof($file_contents) - 1] === false)
+ $diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]);
+ unset($file_contents);
+
+ // Handle conflicts
+ if ($diff->get_num_conflicts() !== 0)
{
- $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff));
- unset($file_contents);
- throw new user_interaction_required_exception();
+ $merge_conflicts[] = $filename;
}
- }
- $diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]);
- unset($file_contents);
+ // Save merged output
+ $this->cache->put(
+ '_file_' . md5($filename),
+ base64_encode(implode("\n", $diff->merged_output()))
+ );
- // Handle conflicts
- if ($diff->get_num_conflicts() !== 0)
- {
- $merge_conflicts[] = $filename;
+ unset($diff);
}
+ else
+ {
+ $new_file_content = file_get_contents($new_path . $filename);
- // Save merged output
- $this->cache->put(
- '_file_' . md5($filename),
- base64_encode(implode("\n", $diff->merged_output()))
- );
+ if ($new_file_content === false)
+ {
+ $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff));
+ unset($new_file_content );
+ throw new user_interaction_required_exception();
+ }
- unset($diff);
+ // Save new file content to cache
+ $this->cache->put(
+ '_file_' . md5($filename),
+ base64_encode($new_file_content)
+ );
+ unset($new_file_content);
+ }
$progress_count++;
$this->iohandler->set_progress('UPDATE_FILE_DIFF', $progress_count);