| 11316 | | sub restore_file { |
|---|
| 11317 | | my $app = shift; |
|---|
| 11318 | | my ($fh, $errormsg) = @_; |
|---|
| 11319 | | my $q = $app->param; |
|---|
| 11320 | | |
|---|
| 11321 | | require MT::BackupRestore; |
|---|
| 11322 | | my $deferred = MT::BackupRestore->restore_file($fh, $errormsg, sub { $app->print(@_); }); |
|---|
| 11323 | | |
|---|
| 11324 | | if (!defined($deferred) || scalar(keys %$deferred)) { |
|---|
| 11325 | | my @names = keys %$deferred; |
|---|
| 11326 | | my $data = ''; |
|---|
| 11327 | | $data .= join(',', splice(@names, 0, 5)) . "\n" while @names; |
|---|
| 11328 | | $data = "Objects which were not restored are listed below (#ID is the id value in the backup file):\n" . $data; |
|---|
| 11329 | | my $message = $app->translate('Some objects were not restored because their parent objects were not restored.'); |
|---|
| | 11316 | sub _log_dirty_restore { |
|---|
| | 11317 | my $app = shift; |
|---|
| | 11318 | my ($deferred) = @_; |
|---|
| | 11319 | my %deferred_by_class; |
|---|
| | 11320 | for my $key (keys %$deferred) { |
|---|
| | 11321 | my ($class, $id) = split('#', $key); |
|---|
| | 11322 | if (exists $deferred_by_class{$class}) { |
|---|
| | 11323 | push @{$deferred_by_class{$class}}, $id; |
|---|
| | 11324 | } else { |
|---|
| | 11325 | $deferred_by_class{$class} = [ $id ]; |
|---|
| | 11326 | |
|---|
| | 11327 | } |
|---|
| | 11328 | } |
|---|
| | 11329 | while (my ($class_name, $ids) = each %deferred_by_class) { |
|---|
| | 11330 | my $message = $app->translate('Some [_1] were not restored because their parent objects were not restored.', $class_name); |
|---|
| 11399 | | my @names = keys %$deferred; |
|---|
| 11400 | | my $data = ''; |
|---|
| 11401 | | $data .= join(',', splice(@names, 0, 5)) . "\n" while @names; |
|---|
| 11402 | | $data = "Objects which were not restored are listed below (#ID is the id value in the backup file):\n" . $data; |
|---|
| 11403 | | my $message = $app->translate('Some objects were not restored because their parent objects were not restored.'); |
|---|
| 11404 | | $app->log({ |
|---|
| 11405 | | message => $message, |
|---|
| 11406 | | level => MT::Log::WARNING(), |
|---|
| 11407 | | class => 'system', |
|---|
| 11408 | | category => 'restore', |
|---|
| 11409 | | metadata => $data, |
|---|
| 11410 | | }); |
|---|
| | 11413 | $app->_log_dirty_restore($deferred); |
|---|
| 11625 | | my @names = keys %$deferred; |
|---|
| 11626 | | my $data = ''; |
|---|
| 11627 | | $data .= join(',', splice(@names, 0, 5)) . "\n" while @names; |
|---|
| 11628 | | $data = "Objects which were not restored are listed below (#ID is the id value in the backup file):\n" . $data; |
|---|
| 11629 | | my $message = $app->translate('Some objects were not restored because their parent objects were not restored.'); |
|---|
| 11630 | | $app->log({ |
|---|
| 11631 | | message => $message, |
|---|
| 11632 | | level => MT::Log::WARNING(), |
|---|
| 11633 | | class => 'system', |
|---|
| 11634 | | category => 'restore', |
|---|
| 11635 | | metadata => $data, |
|---|
| 11636 | | }); |
|---|
| | 11628 | $app->_log_dirty_restore($deferred); |
|---|
| 11673 | | my @names = keys %$deferred; |
|---|
| 11674 | | my $data = ''; |
|---|
| 11675 | | $data .= join(',', splice(@names, 0, 5)) . "\n" while @names; |
|---|
| 11676 | | $data = "Objects which were not restored are listed below (#ID is the id value in the backup file):\n" . $data; |
|---|
| 11677 | | my $message = $app->translate('Some objects were not restored because their parent objects were not restored.'); |
|---|
| 11678 | | $app->log({ |
|---|
| 11679 | | message => $message, |
|---|
| 11680 | | level => MT::Log::WARNING(), |
|---|
| 11681 | | class => 'system', |
|---|
| 11682 | | category => 'restore', |
|---|
| 11683 | | metadata => $data, |
|---|
| 11684 | | }); |
|---|
| | 11665 | $app->_log_dirty_restore($deferred); |
|---|