aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/install
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2010-03-02 01:05:40 +0100
committerNils Adermann <naderman@naderman.de>2010-03-02 01:05:40 +0100
commitf0eb18fffd11a97383c8ccf2ae7d2838939f09e2 (patch)
tree70790196713789f9cbe4609f9e841f7e69bb6f00 /phpBB/install
parent021c186be91095397d4e76801738373989360a52 (diff)
parentac5995551ba941b2cb5d98cc86ffe921bedee200 (diff)
downloadforums-f0eb18fffd11a97383c8ccf2ae7d2838939f09e2.tar
forums-f0eb18fffd11a97383c8ccf2ae7d2838939f09e2.tar.gz
forums-f0eb18fffd11a97383c8ccf2ae7d2838939f09e2.tar.bz2
forums-f0eb18fffd11a97383c8ccf2ae7d2838939f09e2.tar.xz
forums-f0eb18fffd11a97383c8ccf2ae7d2838939f09e2.zip
Merge commit 'release-3.0.6-RC2'
Diffstat (limited to 'phpBB/install')
-rw-r--r--phpBB/install/convertors/convert_phpbb20.php6
-rw-r--r--phpBB/install/database_update.php283
-rw-r--r--phpBB/install/install_update.php203
-rw-r--r--phpBB/install/schemas/schema_data.sql2
4 files changed, 393 insertions, 101 deletions
diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php
index f4fc466ac7..5a6603883b 100644
--- a/phpBB/install/convertors/convert_phpbb20.php
+++ b/phpBB/install/convertors/convert_phpbb20.php
@@ -31,8 +31,8 @@ unset($dbpasswd);
*/
$convertor_data = array(
'forum_name' => 'phpBB 2.0.x',
- 'version' => '1.0.2',
- 'phpbb_version' => '3.0.4',
+ 'version' => '1.0.3',
+ 'phpbb_version' => '3.0.6',
'author' => '<a href="http://www.phpbb.com/">phpBB Group</a>',
'dbms' => $dbms,
'dbhost' => $dbhost,
@@ -129,7 +129,7 @@ $config_schema = array(
'board_timezone' => 'board_timezone',
'allow_privmsg' => 'not(privmsg_disable)',
'gzip_compress' => 'gzip_compress',
- 'coppa_enable' => 'is_empty(coppa_mail)',
+ 'coppa_enable' => '!is_empty(coppa_mail)',
'coppa_fax' => 'coppa_fax',
'coppa_mail' => 'coppa_mail',
'record_online_users' => 'record_online_users',
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 41983400fc..7ef76535d3 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -8,7 +8,7 @@
*
*/
-$updates_to_version = '3.0.6-RC1';
+$updates_to_version = '3.0.6-RC2';
// Enter any version to update from to test updates. The version within the db will not be updated.
$debug_from_version = false;
@@ -868,9 +868,6 @@ function database_update_info()
),
),
'add_index' => array(
- LOG_TABLE => array(
- 'log_time' => array('log_time'),
- ),
REPORTS_TABLE => array(
'post_id' => array('post_id'),
'pm_id' => array('pm_id'),
@@ -880,6 +877,12 @@ function database_update_info()
),
),
),
+ // Changes from 3.0.6-RC1 to 3.0.6-RC2
+ '3.0.6-RC1' => array(
+ 'drop_keys' => array(
+ LOG_TABLE => array('log_time'),
+ ),
+ ),
);
}
@@ -1506,6 +1509,10 @@ function change_database_data(&$no_updates, $version)
$no_updates = false;
break;
+
+ // No changes from 3.0.6-RC1 to 3.0.6-RC2
+ case '3.0.6-RC1':
+ break;
}
}
@@ -1902,7 +1909,8 @@ class updater_db_tools
{
if ($column_exists)
{
- $sqlite_data[$table]['change_columns'][] = $result;
+ continue;
+// $sqlite_data[$table]['change_columns'][] = $result;
}
else
{
@@ -1924,6 +1932,11 @@ class updater_db_tools
{
foreach ($indexes as $index_name)
{
+ if (!$this->sql_index_exists($table, $index_name))
+ {
+ continue;
+ }
+
$result = $this->sql_index_drop($table, $index_name);
if ($this->return_statements)
@@ -1984,6 +1997,11 @@ class updater_db_tools
{
foreach ($index_array as $index_name => $column)
{
+ if ($this->sql_unique_index_exists($table, $index_name))
+ {
+ continue;
+ }
+
$result = $this->sql_create_unique_index($table, $index_name, $column);
if ($this->return_statements)
@@ -2001,6 +2019,11 @@ class updater_db_tools
{
foreach ($index_array as $index_name => $column)
{
+ if ($this->sql_index_exists($table, $index_name))
+ {
+ continue;
+ }
+
$result = $this->sql_create_index($table, $index_name, $column);
if ($this->return_statements)
@@ -2309,6 +2332,229 @@ class updater_db_tools
}
/**
+ * Check if a specified index exists in table. Does not return PRIMARY KEY and UNIQUE indexes.
+ *
+ * @param string $table_name Table to check the index at
+ * @param string $index_name The index name to check
+ *
+ * @return bool True if index exists, else false
+ */
+ function sql_index_exists($table_name, $index_name)
+ {
+ if ($this->sql_layer == 'mssql')
+ {
+ $sql = "EXEC sp_statistics '$table_name'";
+ $result = $this->db->sql_query($sql);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if ($row['TYPE'] == 3)
+ {
+ if (strtolower($row['INDEX_NAME']) == strtolower($index_name))
+ {
+ $this->db->sql_freeresult($result);
+ return true;
+ }
+ }
+ }
+ $this->db->sql_freeresult($result);
+
+ return false;
+ }
+
+ switch ($this->sql_layer)
+ {
+ case 'firebird':
+ $sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name
+ FROM RDB\$INDICES
+ WHERE RDB\$RELATION_NAME = '" . strtoupper($table_name) . "'
+ AND RDB\$UNIQUE_FLAG IS NULL
+ AND RDB\$FOREIGN_KEY IS NULL";
+ $col = 'index_name';
+ break;
+
+ case 'postgres':
+ $sql = "SELECT ic.relname as index_name
+ FROM pg_class bc, pg_class ic, pg_index i
+ WHERE (bc.oid = i.indrelid)
+ AND (ic.oid = i.indexrelid)
+ AND (bc.relname = '" . $table_name . "')
+ AND (i.indisunique != 't')
+ AND (i.indisprimary != 't')";
+ $col = 'index_name';
+ break;
+
+ case 'mysql_40':
+ case 'mysql_41':
+ $sql = 'SHOW KEYS
+ FROM ' . $table_name;
+ $col = 'Key_name';
+ break;
+
+ case 'oracle':
+ $sql = "SELECT index_name
+ FROM user_indexes
+ WHERE table_name = '" . strtoupper($table_name) . "'
+ AND generated = 'N'
+ AND uniqueness = 'NONUNIQUE'";
+ $col = 'index_name';
+ break;
+
+ case 'sqlite':
+ $sql = "PRAGMA index_list('" . $table_name . "');";
+ $col = 'name';
+ break;
+ }
+
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && !$row['Non_unique'])
+ {
+ continue;
+ }
+
+ // These DBMS prefix index name with the table name
+ switch ($this->sql_layer)
+ {
+ case 'firebird':
+ case 'oracle':
+ case 'postgres':
+ case 'sqlite':
+ $row[$col] = substr($row[$col], strlen($table_name) + 1);
+ break;
+ }
+
+ if (strtolower($row[$col]) == strtolower($index_name))
+ {
+ $this->db->sql_freeresult($result);
+ return true;
+ }
+ }
+ $this->db->sql_freeresult($result);
+
+ return false;
+ }
+
+ /**
+ * Check if a specified UNIQUE index exists in table.
+ *
+ * @param string $table_name Table to check the index at
+ * @param string $index_name The index name to check
+ *
+ * @return bool True if index exists, else false
+ */
+ function sql_unique_index_exists($table_name, $index_name)
+ {
+ if ($this->sql_layer == 'mssql')
+ {
+ $sql = "EXEC sp_statistics '$table_name'";
+ $result = $this->db->sql_query($sql);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ // Usually NON_UNIQUE is the column we want to check, but we allow for both
+ if ($row['TYPE'] == 3)
+ {
+ if (strtolower($row['INDEX_NAME']) == strtolower($index_name))
+ {
+ $this->db->sql_freeresult($result);
+ return true;
+ }
+ }
+ }
+ $this->db->sql_freeresult($result);
+ return false;
+ }
+
+ switch ($this->sql_layer)
+ {
+ case 'firebird':
+ $sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name
+ FROM RDB\$INDICES
+ WHERE RDB\$RELATION_NAME = '" . strtoupper($table_name) . "'
+ AND RDB\$UNIQUE_FLAG IS NOT NULL
+ AND RDB\$FOREIGN_KEY IS NULL";
+ $col = 'index_name';
+ break;
+
+ case 'postgres':
+ $sql = "SELECT ic.relname as index_name, i.indisunique
+ FROM pg_class bc, pg_class ic, pg_index i
+ WHERE (bc.oid = i.indrelid)
+ AND (ic.oid = i.indexrelid)
+ AND (bc.relname = '" . $table_name . "')
+ AND (i.indisprimary != 't')";
+ $col = 'index_name';
+ break;
+
+ case 'mysql_40':
+ case 'mysql_41':
+ $sql = 'SHOW KEYS
+ FROM ' . $table_name;
+ $col = 'Key_name';
+ break;
+
+ case 'oracle':
+ $sql = "SELECT index_name, table_owner
+ FROM user_indexes
+ WHERE table_name = '" . strtoupper($table_name) . "'
+ AND generated = 'N'
+ AND uniqueness = 'UNIQUE'
+ AND index_name LIKE 'U_%'";
+ $col = 'index_name';
+ break;
+
+ case 'sqlite':
+ $sql = "PRAGMA index_list('" . $table_name . "') WHERE unique = 1;";
+ $col = 'name';
+ break;
+ }
+
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && ($row['Non_unique'] || $row[$col] == 'PRIMARY'))
+ {
+ continue;
+ }
+
+ if ($this->sql_layer == 'sqlite' && !$row['unique'])
+ {
+ continue;
+ }
+
+ if ($this->sql_layer == 'postgres' && $row['indisunique'] != 't')
+ {
+ continue;
+ }
+
+ // These DBMS prefix index name with the table name
+ switch ($this->sql_layer)
+ {
+ case 'oracle':
+ $row[$col] = substr($row[$col], strlen('U_' . $row['table_owner']) + 1);
+ break;
+
+ case 'firebird':
+ case 'postgres':
+ case 'sqlite':
+ $row[$col] = substr($row[$col], strlen($table_name) + 1);
+ break;
+ }
+
+ if (strtolower($row[$col]) == strtolower($index_name))
+ {
+ $this->db->sql_freeresult($result);
+ return true;
+ }
+ }
+ $this->db->sql_freeresult($result);
+
+ return false;
+ }
+
+ /**
* Private method for performing sql statements (either execute them or return them)
* @access private
*/
@@ -2441,11 +2687,13 @@ class updater_db_tools
// For hexadecimal values do not use single quotes
if (strpos($column_data[1], '0x') === 0)
{
- $sql_default .= 'DEFAULT (' . $column_data[1] . ') ';
+ $return_array['default'] = 'DEFAULT (' . $column_data[1] . ') ';
+ $sql_default .= $return_array['default'];
}
else
{
- $sql_default .= 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') ';
+ $return_array['default'] = 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') ';
+ $sql_default .= $return_array['default'];
}
}
@@ -2965,6 +3213,27 @@ class updater_db_tools
case 'mssql':
$statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql'];
+
+ if (!empty($column_data['default']))
+ {
+ // Using TRANSACT-SQL for this statement because we do not want to have colliding data if statements are executed at a later stage
+ $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000)
+ SET @drop_default_name =
+ (SELECT so.name FROM sysobjects so
+ JOIN sysconstraints sc ON so.id = sc.constid
+ WHERE object_name(so.parent_obj) = '{$table_name}'
+ AND so.xtype = 'D'
+ AND sc.colid = (SELECT colid FROM syscolumns
+ WHERE id = object_id('{$table_name}')
+ AND name = '{$column_name}'))
+ IF @drop_default_name <> ''
+ BEGIN
+ SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']'
+ EXEC(@cmd)
+ END
+ SET @cmd = 'ALTER TABLE [{$table_name}] ADD CONSTRAINT [DF_{$table_name}_{$column_name}_1] {$column_data['default']} FOR [{$column_name}]'
+ EXEC(@cmd)";
+ }
break;
case 'mysql_40':
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index ad72652e97..ab7ec35705 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -687,7 +687,7 @@ class install_update extends module
default:
$diff = $this->return_diff($this->old_location . $original_filename, $phpbb_root_path . $file_struct['filename'], $this->new_location . $original_filename);
- $contents = implode("\n", $diff->merged_new_output());
+ $contents = implode("\n", $diff->merged_output());
unset($diff);
break;
}
@@ -1104,24 +1104,6 @@ class install_update extends module
break;
-/*
- $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $file, $this->new_location . $original_file);
-
- $tmp = array(
- 'file1' => array(),
- 'file2' => ($option == MERGE_NEW_FILE) ? implode("\n", $diff->merged_new_output()) : implode("\n", $diff->merged_orig_output()),
- );
-
- $diff = new diff($tmp['file1'], $tmp['file2']);
-
- unset($tmp);
-
- $template->assign_var('S_DIFF_NEW_FILE', true);
- $diff_mode = 'inline';
- $this->page_title = 'VIEWING_FILE_CONTENTS';
-
- break;
-*/
// Merge differences and use new phpBB code for conflicted blocks
case MERGE_NEW_FILE:
case MERGE_MOD_FILE:
@@ -1175,6 +1157,7 @@ class install_update extends module
default:
$diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $original_file, $this->new_location . $file);
+ $diff = $this->return_diff($phpbb_root_path . $file, $diff->merged_output());
break;
}
break;
@@ -1362,6 +1345,9 @@ class install_update extends module
$update_ary['original'] = $original_file;
}
+ // we only want to know if the files are successfully merged and newlines could result in errors (duplicate addition of lines and such things)
+ // Therefore we check for empty diffs with two methods, preserving newlines and not preserving them (which mostly works best, therefore the first option)
+
// On a successfull update the new location file exists but the old one does not exist.
// Check for this circumstance, the new file need to be up-to-date with the current file then...
if (!file_exists($this->old_location . $original_file) && file_exists($this->new_location . $original_file) && file_exists($phpbb_root_path . $file))
@@ -1401,104 +1387,141 @@ class install_update extends module
trigger_error($user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR);
}
- $tmp = array(
- 'file1' => file_get_contents($this->old_location . $original_file),
- 'file2' => file_get_contents($phpbb_root_path . $file),
- );
+ $preserve_cr_ary = array(false, true);
+
+ foreach ($preserve_cr_ary as $preserve_cr)
+ {
+ $tmp = array(
+ 'file1' => file_get_contents($this->old_location . $original_file),
+ 'file2' => file_get_contents($phpbb_root_path . $file),
+ );
+
+ // We need to diff the contents here to make sure the file is really the one we expect
+ $diff = new diff($tmp['file1'], $tmp['file2'], $preserve_cr);
+ $empty_1 = $diff->is_empty();
+
+ unset($tmp, $diff);
- // We need to diff the contents here to make sure the file is really the one we expect
- $diff = new diff($tmp['file1'], $tmp['file2'], false);
- $empty_1 = $diff->is_empty();
+ $tmp = array(
+ 'file1' => file_get_contents($this->new_location . $original_file),
+ 'file2' => file_get_contents($phpbb_root_path . $file),
+ );
- unset($tmp, $diff);
+ $diff = new diff($tmp['file1'], $tmp['file2'], $preserve_cr);
+ $empty_2 = $diff->is_empty();
- $tmp = array(
- 'file1' => file_get_contents($this->new_location . $original_file),
- 'file2' => file_get_contents($phpbb_root_path . $file),
- );
+ unset($tmp, $diff);
- // We need to diff the contents here to make sure the file is really the one we expect
- $diff = new diff($tmp['file1'], $tmp['file2'], false);
- $empty_2 = $diff->is_empty();
+ // If the file is not modified we are finished here...
+ if ($empty_1)
+ {
+ // Further check if it is already up to date - it could happen that non-modified files
+ // slip through
+ if ($empty_2)
+ {
+ $update_list['up_to_date'][] = $update_ary;
+ return;
+ }
- unset($tmp, $diff);
+ $update_list['not_modified'][] = $update_ary;
+ return;
+ }
- // If the file is not modified we are finished here...
- if ($empty_1)
- {
- // Further check if it is already up to date - it could happen that non-modified files
- // slip through
+ // If the file had been modified then we need to check if it is already up to date
+
+ // if there are no differences we have an up-to-date file...
if ($empty_2)
{
$update_list['up_to_date'][] = $update_ary;
return;
}
-
- $update_list['not_modified'][] = $update_ary;
- return;
}
- // If the file had been modified then we need to check if it is already up to date
+ $conflicts = false;
- // if there are no differences we have an up-to-date file...
- if ($empty_2)
+ foreach ($preserve_cr_ary as $preserve_cr)
{
- $update_list['up_to_date'][] = $update_ary;
- return;
- }
-
- // if the file is modified we try to make sure a merge succeed
- $tmp = array(
- 'file1' => file_get_contents($this->old_location . $original_file),
- 'file2' => file_get_contents($phpbb_root_path . $file),
- 'file3' => file_get_contents($this->new_location . $original_file),
- );
+ // if the file is modified we try to make sure a merge succeed
+ $tmp = array(
+ 'orig' => file_get_contents($this->old_location . $original_file),
+ 'final1' => file_get_contents($phpbb_root_path . $file),
+ 'final2' => file_get_contents($this->new_location . $original_file),
+ );
- $diff = new diff3($tmp['file1'], $tmp['file2'], $tmp['file3'], false);
+ $diff = new diff3($tmp['orig'], $tmp['final1'], $tmp['final2'], $preserve_cr);
+ unset($tmp);
- unset($tmp);
+ if (!$diff->get_num_conflicts())
+ {
+ $tmp = array(
+ 'file1' => file_get_contents($phpbb_root_path . $file),
+ 'file2' => implode("\n", $diff->merged_output()),
+ );
- if ($diff->get_num_conflicts())
- {
- $update_ary['conflicts'] = $diff->get_num_conflicts();
+ // now compare the merged output with the original file to see if the modified file is up to date
+ $diff2 = new diff($tmp['file1'], $tmp['file2'], $preserve_cr);
+ $empty = $diff2->is_empty();
- // There is one special case... users having merged with a conflicting file... we need to check this
- $tmp = array(
- 'file1' => file_get_contents($phpbb_root_path . $file),
- 'file2' => implode("\n", $diff->merged_orig_output()),
- );
+ unset($diff, $diff2);
- $diff = new diff($tmp['file1'], $tmp['file2'], false);
- $empty = $diff->is_empty();
+ if ($empty)
+ {
+ $update_list['up_to_date'][] = $update_ary;
+ return;
+ }
- if ($empty)
- {
- unset($update_ary['conflicts']);
- unset($diff);
- $update_list['up_to_date'][] = $update_ary;
- return;
+ // If we preserve cr tag it as modified because the conflict would not show in this mode anyway
+ if ($preserve_cr)
+ {
+ $update_list['modified'][] = $update_ary;
+ return;
+ }
}
+ else
+ {
+ // There is one special case... users having merged with a conflicting file... we need to check this
+ $tmp = array(
+ 'file1' => file_get_contents($phpbb_root_path . $file),
+ 'file2' => implode("\n", $diff->merged_new_output()),
+ );
- $update_list['conflict'][] = $update_ary;
- unset($diff);
+ $diff2 = new diff($tmp['file1'], $tmp['file2'], $preserve_cr);
+ $empty = $diff2->is_empty();
- return;
- }
+ if (!$empty)
+ {
+ unset($tmp, $diff2);
- $tmp = array(
- 'file1' => file_get_contents($phpbb_root_path . $file),
- 'file2' => implode("\n", $diff->merged_new_output()),
- );
+ // We check if the user merged with his output
+ $tmp = array(
+ 'file1' => file_get_contents($phpbb_root_path . $file),
+ 'file2' => implode("\n", $diff->merged_orig_output()),
+ );
- // now compare the merged output with the original file to see if the modified file is up to date
- $diff = new diff($tmp['file1'], $tmp['file2'], false);
- $empty = $diff->is_empty();
+ $diff2 = new diff($tmp['file1'], $tmp['file2'], $preserve_cr);
+ $empty = $diff2->is_empty();
+ }
- if ($empty)
- {
- unset($diff);
+ if (!$empty)
+ {
+ $conflicts = $diff->get_num_conflicts();
+ }
+
+ unset($diff, $diff2);
+
+ if ($empty)
+ {
+ // A conflict got resolved...
+ $update_list['up_to_date'][] = $update_ary;
+ return;
+ }
+ }
+ }
- $update_list['up_to_date'][] = $update_ary;
+ if ($conflicts !== false)
+ {
+ $update_ary['conflicts'] = $conflicts;
+ $update_list['conflict'][] = $update_ary;
return;
}
@@ -1650,7 +1673,7 @@ class install_update extends module
/**
* Wrapper for returning a diff object
*/
- function &return_diff()
+ function return_diff()
{
$args = func_get_args();
$three_way_diff = (func_num_args() > 2) ? true : false;
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index 5c653afc41..18bd8d8e9a 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -239,7 +239,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('topics_per_page',
INSERT INTO phpbb_config (config_name, config_value) VALUES ('tpl_allow_php', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_icons_path', 'images/upload_icons');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_path', 'files');
-INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.6-RC1');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.6-RC2');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_expire_days', '90');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_gc', '14400');