Bulk import/export adjustment to prevent zip uploader overlap so the test won't bomb
This commit is contained in:
parent
d14c2ce8ea
commit
8dd5ad16f3
1 changed files with 23 additions and 11 deletions
|
@ -17,18 +17,12 @@ class BulkImportExport extends DataHandlerExtension
|
||||||
$zip = new ZipArchive;
|
$zip = new ZipArchive;
|
||||||
|
|
||||||
if ($zip->open($event->tmpname) === true) {
|
if ($zip->open($event->tmpname) === true) {
|
||||||
$info = $zip->getStream(self::EXPORT_INFO_FILE_NAME);
|
$json_data = $this->get_export_data($zip);
|
||||||
$json_data = [];
|
|
||||||
if ($info !== false) {
|
if(empty($json_data)) {
|
||||||
try {
|
return;
|
||||||
$json_string = stream_get_contents($info);
|
|
||||||
$json_data = json_decode($json_string);
|
|
||||||
} finally {
|
|
||||||
fclose($info);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new SCoreException("Could not get " . self::EXPORT_INFO_FILE_NAME . " from archive");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$skipped = 0;
|
$skipped = 0;
|
||||||
$failed = 0;
|
$failed = 0;
|
||||||
|
@ -169,4 +163,22 @@ class BulkImportExport extends DataHandlerExtension
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function get_export_data(ZipArchive $zip): ?array
|
||||||
|
{
|
||||||
|
$info = $zip->getStream(self::EXPORT_INFO_FILE_NAME);
|
||||||
|
$json_data = [];
|
||||||
|
if ($info !== false) {
|
||||||
|
try {
|
||||||
|
$json_string = stream_get_contents($info);
|
||||||
|
$json_data = json_decode($json_string);
|
||||||
|
} finally {
|
||||||
|
fclose($info);
|
||||||
|
}
|
||||||
|
return $json_data;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue