Bug 72826 - Fix migrate.pl (LONGBLOB columns), change CodeError to UserError in token.cgi
git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1189 6955db30-a419-402b-8a0d-67ecbb4d7f56master
parent
40b9f50e14
commit
c72334e5ba
|
@ -7,6 +7,9 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
my ($from, $from_user, $from_password);
|
||||||
|
my @ignore_tables;
|
||||||
|
|
||||||
# Runs before any 'uses'
|
# Runs before any 'uses'
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
|
@ -29,9 +32,6 @@ Does the following:
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Parse command-line arguments
|
# Parse command-line arguments
|
||||||
my ($from, $from_user, $from_password);
|
|
||||||
my @ignore_tables;
|
|
||||||
|
|
||||||
while ($_ = shift @ARGV)
|
while ($_ = shift @ARGV)
|
||||||
{
|
{
|
||||||
if ($_ eq '--from')
|
if ($_ eq '--from')
|
||||||
|
@ -94,7 +94,7 @@ my %seen_tables = (
|
||||||
);
|
);
|
||||||
|
|
||||||
# Ignore more tables
|
# Ignore more tables
|
||||||
$seen_tables = 1 for @ignore_tables;
|
$seen_tables{$_} = 1 for @ignore_tables;
|
||||||
|
|
||||||
my %field_exclude = (
|
my %field_exclude = (
|
||||||
'fieldvaluecontrol' => 'field_id',
|
'fieldvaluecontrol' => 'field_id',
|
||||||
|
@ -151,6 +151,8 @@ for (values %$fielddefs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my (@skip_fields, $maxkey);
|
||||||
|
|
||||||
print "Redefine existing fields\n";
|
print "Redefine existing fields\n";
|
||||||
$to->do('DELETE FROM profiles_activity'); #!
|
$to->do('DELETE FROM profiles_activity'); #!
|
||||||
$to->do('DELETE FROM fielddefs WHERE name IN (\''.join('\',\'', keys %$fieldsnew).'\')'); #!
|
$to->do('DELETE FROM fielddefs WHERE name IN (\''.join('\',\'', keys %$fieldsnew).'\')'); #!
|
||||||
|
@ -158,8 +160,6 @@ insertall_hashref($to, 'fielddefs', [ map { $fielddefs->{$_} } keys %$fieldsnew
|
||||||
|
|
||||||
delete $fielddefs->{$_} for keys %$fieldsnew;
|
delete $fielddefs->{$_} for keys %$fieldsnew;
|
||||||
|
|
||||||
my @skip_fields;
|
|
||||||
|
|
||||||
for (keys %$fielddefs)
|
for (keys %$fielddefs)
|
||||||
{
|
{
|
||||||
if ($fielddefs->{$_}->{obsolete})
|
if ($fielddefs->{$_}->{obsolete})
|
||||||
|
@ -183,9 +183,11 @@ for (keys %$fielddefs)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Alter fielddefs autoincrement value manually
|
# Alter fielddefs autoincrement value manually
|
||||||
my ($maxkey) = $to->selectrow_array('SELECT MAX(id) FROM fielddefs');
|
($maxkey) = $to->selectrow_array('SELECT MAX(id) FROM fielddefs');
|
||||||
alter_sequence($to, 'fielddefs', 'id', $maxkey);
|
alter_sequence($to, 'fielddefs', 'id', $maxkey);
|
||||||
|
|
||||||
|
$to->{RaiseError} = 0;
|
||||||
|
$to->{PrintError} = 1;
|
||||||
for my $table (@copy_tables)
|
for my $table (@copy_tables)
|
||||||
{
|
{
|
||||||
print "Selecting $table\n";
|
print "Selecting $table\n";
|
||||||
|
@ -247,6 +249,11 @@ sub alter_sequence
|
||||||
{
|
{
|
||||||
$dbh->do("ALTER SEQUENCE ${table}_${field}_seq RESTART WITH $maxkey");
|
$dbh->do("ALTER SEQUENCE ${table}_${field}_seq RESTART WITH $maxkey");
|
||||||
}
|
}
|
||||||
|
elsif ($dbh->isa('Bugzilla::DB::Oracle'))
|
||||||
|
{
|
||||||
|
my @sql = $dbh->_bz_real_schema->_get_create_seq_ddl($table, $field, $maxkey);
|
||||||
|
$dbh->do($_) foreach @sql;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Insert an array of hashes into a database table
|
# Insert an array of hashes into a database table
|
||||||
|
@ -256,12 +263,32 @@ sub insertall_hashref
|
||||||
return 0 unless
|
return 0 unless
|
||||||
$dbh && $table &&
|
$dbh && $table &&
|
||||||
$rows && ref($rows) eq 'ARRAY' && @$rows;
|
$rows && ref($rows) eq 'ARRAY' && @$rows;
|
||||||
my $q = substr($dbh->quote_identifier('a'), 0, 1);
|
|
||||||
my @f = keys %{$rows->[0]};
|
my @f = keys %{$rows->[0]};
|
||||||
my $sql = "INSERT INTO $q$table$q ($q".join("$q,$q",@f)."$q) VALUES ".
|
my $k = join "|", $table, @f, scalar @$rows;
|
||||||
join(',',('('.(join(',', ('?') x scalar(@f))).')') x scalar(@$rows));
|
my $sth;
|
||||||
my @bind = map { @$_{@f} } @$rows;
|
if (!($sth = $dbh->{__insertall_hashref_cache}->{$k}))
|
||||||
return $dbh->do($sql, undef, @bind);
|
{
|
||||||
|
my $q = substr($dbh->quote_identifier('a'), 0, 1);
|
||||||
|
$sth = $dbh->prepare(
|
||||||
|
"INSERT INTO $q$table$q ($q".join("$q,$q", @f)."$q) VALUES ".
|
||||||
|
join(',', ('('.(join(',', ('?') x @f)).')') x scalar @$rows)
|
||||||
|
);
|
||||||
|
if ($dbh->isa('Bugzilla::DB::Pg') || $dbh->isa('Bugzilla::DB::Oracle'))
|
||||||
|
{
|
||||||
|
for my $i (0 .. $#f)
|
||||||
|
{
|
||||||
|
if ($dbh->bz_column_info($table, $f[$i])->{TYPE} eq 'LONGBLOB')
|
||||||
|
{
|
||||||
|
for my $j (0 .. $#$rows)
|
||||||
|
{
|
||||||
|
$sth->bind_param(1 + $i + $j*@f, '', $dbh->BLOB_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$dbh->{__insertall_hashref_cache}->{$k} = $sth;
|
||||||
|
}
|
||||||
|
return $sth->execute(map { @$_{@f} } @$rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get node sequence from a dependency graph
|
# Get node sequence from a dependency graph
|
||||||
|
|
|
@ -1707,6 +1707,13 @@
|
||||||
[% title = "Illegal User ID" %]
|
[% title = "Illegal User ID" %]
|
||||||
User ID '[% userid FILTER html %]' is not valid integer.
|
User ID '[% userid FILTER html %]' is not valid integer.
|
||||||
|
|
||||||
|
[% ELSIF error == "unknown_action" %]
|
||||||
|
[% IF action %]
|
||||||
|
Unknown action [% action FILTER html %]!
|
||||||
|
[% ELSE %]
|
||||||
|
I could not figure out what you wanted to do.
|
||||||
|
[% END %]
|
||||||
|
|
||||||
[% ELSE %]
|
[% ELSE %]
|
||||||
[%# Try to find hooked error messages %]
|
[%# Try to find hooked error messages %]
|
||||||
[% error_message = Hook.process("errors") %]
|
[% error_message = Hook.process("errors") %]
|
||||||
|
|
|
@ -56,7 +56,7 @@ Bugzilla->login(LOGIN_OPTIONAL);
|
||||||
|
|
||||||
# Throw an error if the form does not contain an "action" field specifying
|
# Throw an error if the form does not contain an "action" field specifying
|
||||||
# what the user wants to do.
|
# what the user wants to do.
|
||||||
$action || ThrowCodeError("unknown_action");
|
$action || ThrowUserError("unknown_action");
|
||||||
|
|
||||||
# If a token was submitted, make sure it is a valid token that exists in the
|
# If a token was submitted, make sure it is a valid token that exists in the
|
||||||
# database and is the correct type for the action being taken.
|
# database and is the correct type for the action being taken.
|
||||||
|
|
Loading…
Reference in New Issue