1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-09 18:26:32 +02:00

Merge branch 'develop-olympus' into develop

* develop-olympus:
  [ticket/9892] Correct copyright year
  [ticket/9892] Remove incorrect use of camel case
  [ticket/9892] Removing closing php tag from create_schema_files
  [ticket/9892] Transaction support for database update sql execution function
  [ticket/9892] count is a keyword in firebird, so renaming this alias
  [ticket/9892] Q&A CAPTCHA did not work on firebird, so no need to change config
  [ticket/9892] Shorten login_attempt key names to avoid firebird length problems
  [ticket/9892] Drop Q&A CAPTCHA tables if left in inconsistent state
  [ticket/9892] Adding a number of tests for db_tools
  [ticket/9892] Table prefix lengths influence index lengths in db_tools
  [ticket/9892] Shorten the index names on the q&a captcha
  [ticket/9892] column & index name limits, firebird auto increment in db_tools

Conflicts:
	phpBB/develop/create_schema_files.php
This commit is contained in:
Andreas Fischer
2011-06-12 19:27:01 +02:00
6 changed files with 388 additions and 14 deletions

View File

@@ -601,12 +601,23 @@ function _sql($sql, &$errored, &$error_ary, $echo_dot = true)
$db->sql_return_on_error(true);
$result = $db->sql_query($sql);
if ($db->sql_error_triggered)
if ($sql === 'begin')
{
$errored = true;
$error_ary['sql'][] = $db->sql_error_sql;
$error_ary['error_code'][] = $db->sql_error_returned;
$db->sql_transaction('begin');
}
else if ($sql === 'commit')
{
$db->sql_transaction('commit');
}
else
{
$result = $db->sql_query($sql);
if ($db->sql_error_triggered)
{
$errored = true;
$error_ary['sql'][] = $db->sql_error_sql;
$error_ary['error_code'][] = $db->sql_error_returned;
}
}
$db->sql_return_on_error(false);
@@ -999,9 +1010,9 @@ function database_update_info()
),
'PRIMARY_KEY' => 'attempt_id',
'KEYS' => array(
'attempt_ip' => array('INDEX', array('attempt_ip', 'attempt_time')),
'attempt_forwarded_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')),
'attempt_time' => array('INDEX', array('attempt_time')),
'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')),
'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')),
'att_time' => array('INDEX', array('attempt_time')),
'user_id' => array('INDEX', 'user_id'),
),
),
@@ -1997,6 +2008,27 @@ function change_database_data(&$no_updates, $version)
}
$db->sql_freeresult($result);
global $db_tools, $table_prefix;
// Recover from potentially broken Q&A CAPTCHA table on firebird
// Q&A CAPTCHA was uninstallable, so it's safe to remove these
// without data loss
if ($db_tools->sql_layer == 'firebird')
{
$tables = array(
$table_prefix . 'captcha_questions',
$table_prefix . 'captcha_answers',
$table_prefix . 'qa_confirm',
);
foreach ($tables as $table)
{
if ($db_tools->sql_table_exists($table))
{
$db_tools->sql_table_drop($table);
}
}
}
$no_updates = false;
break;
@@ -2545,6 +2577,11 @@ class updater_db_tools
// here lies an array, filled with information compiled on the column's data
$prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data);
if (isset($prepared_column['auto_increment']) && strlen($column_name) > 26) // "${column_name}_gen"
{
trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum auto increment column length is 26 characters.", E_USER_ERROR);
}
// here we add the definition of the new column to the list of columns
switch ($this->sql_layer)
{
@@ -2694,7 +2731,13 @@ class updater_db_tools
case 'firebird':
if ($create_sequence)
{
$statements[] = "CREATE SEQUENCE {$table_name}_seq;";
$statements[] = "CREATE GENERATOR {$table_name}_gen;";
$statements[] = "SET GENERATOR {$table_name}_gen TO 0;";
$trigger = "CREATE TRIGGER t_$table_name FOR $table_name\n";
$trigger .= "BEFORE INSERT\nAS\nBEGIN\n";
$trigger .= "\tNEW.{$create_sequence} = GEN_ID({$table_name}_gen, 1);\nEND;";
$statements[] = $trigger;
}
break;
}
@@ -3528,6 +3571,11 @@ class updater_db_tools
*/
function sql_prepare_column_data($table_name, $column_name, $column_data)
{
if (strlen($column_name) > 30)
{
trigger_error("Column name '$column_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR);
}
// Get type
if (strpos($column_data[0], ':') !== false)
{
@@ -4101,6 +4149,13 @@ class updater_db_tools
{
$statements = array();
$table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config)
if (strlen($table_name . $index_name) - strlen($table_prefix) > 24)
{
$max_length = $table_prefix + 24;
trigger_error("Index name '{$table_name}_$index_name' on table '$table_name' is too long. The maximum is $max_length characters.", E_USER_ERROR);
}
switch ($this->sql_layer)
{
case 'firebird':
@@ -4131,6 +4186,13 @@ class updater_db_tools
{
$statements = array();
$table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config)
if (strlen($table_name . $index_name) - strlen($table_prefix) > 24)
{
$max_length = $table_prefix + 24;
trigger_error("Index name '{$table_name}_$index_name' on table '$table_name' is too long. The maximum is $max_length characters.", E_USER_ERROR);
}
// remove index length unless MySQL4
if ('mysql_40' != $this->sql_layer)
{