aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/develop/create_schema_files.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-03-28 20:22:10 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-03-29 10:58:17 +0100
commitb3560264e838579871d0e0bdf67ff9102e3e84d5 (patch)
treeefd37c9e7503c4b4bee5c79d3587b1bf0923efea /phpBB/develop/create_schema_files.php
parent18e70d438082f87cccdbb425d2c206059e84049b (diff)
downloadforums-b3560264e838579871d0e0bdf67ff9102e3e84d5.tar
forums-b3560264e838579871d0e0bdf67ff9102e3e84d5.tar.gz
forums-b3560264e838579871d0e0bdf67ff9102e3e84d5.tar.bz2
forums-b3560264e838579871d0e0bdf67ff9102e3e84d5.tar.xz
forums-b3560264e838579871d0e0bdf67ff9102e3e84d5.zip
[ticket/11459] Correctly handle index column length
Code is copied from db\tools::sql_create_index() PHPBB3-11459
Diffstat (limited to 'phpBB/develop/create_schema_files.php')
-rw-r--r--phpBB/develop/create_schema_files.php25
1 files changed, 21 insertions, 4 deletions
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
index 787e620a32..846c80d8fa 100644
--- a/phpBB/develop/create_schema_files.php
+++ b/phpBB/develop/create_schema_files.php
@@ -25,6 +25,7 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
+$finder = $phpbb_extension_manager->get_finder();
$finder = $finder
->core_path('phpbb/db/migration/data/')
->extension_prefix('migration/');
@@ -468,15 +469,27 @@ foreach ($supported_dbms as $dbms)
trigger_error("Index name '${table_name}_$key_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR);
}
+ foreach ($key_data[1] as $key => $col_name)
+ {
+ // remove index length unless MySQL4
+ if ($dbms !== 'mysql_40')
+ {
+ $key_data[1][$key] = preg_replace('#:.*$#', '', $col_name);
+ }
+ }
+
switch ($dbms)
{
case 'mysql_40':
- case 'mysql_41':
- $line .= ($key_data[0] == 'INDEX') ? "\tKEY" : '';
- $line .= ($key_data[0] == 'UNIQUE') ? "\tUNIQUE" : '';
+ // add index size to definition as required by MySQL4
foreach ($key_data[1] as $key => $col_name)
{
- if (isset($modded_array[$col_name]))
+ if (false !== strpos($col_name, ':'))
+ {
+ list($col_name, $index_size) = explode(':', $col_name);
+ $key_data[1][$key] = "$col_name($index_size)";
+ }
+ else if (isset($modded_array[$col_name]))
{
switch ($modded_array[$col_name])
{
@@ -487,6 +500,10 @@ foreach ($supported_dbms as $dbms)
}
}
}
+ // no break
+ case 'mysql_41':
+ $line .= ($key_data[0] == 'INDEX') ? "\tKEY" : '';
+ $line .= ($key_data[0] == 'UNIQUE') ? "\tUNIQUE" : '';
$line .= ' ' . $key_name . ' (' . implode(', ', $key_data[1]) . "),\n";
break;