Answer the question
In order to leave comments, you need to log in
ZipArchive does not appear after closing (php.5.2). How to find out the reason?
At work, now I have to write data migration from one ancient project to a new one. The old project was still in the days of 5.2 and updating it is suicide.
To migrate data, you need to pull the api method of the new project, which expects a zip archive with all documents + a json file with details for the document.
There is an old project with ~3k documents on the test server. 99% of them migrated without problems, about a hundred more documents are not generated in a zip-ku.
At the beginning and at the end of the method, I call error_get_last to make sure that there are no errors, or that no new error has occurred (compared to the beginning of the method).
Here is an example of the resulting log:(the name is replaced by uniqueid(), the paths are smeared due to the presence of the customer's name and the project name. There are no spaces or Cyrillic in the paths.).
self::debugApi('generate a zip file');
$zip = new ZipArchive();
do {
$titleToZip = uniqid();
$zipFileFullPath = $path . DIRECTORY_SEPARATOR . $titleToZip . '.zip';
} while (file_exists($zipFileFullPath));
$zipCreateSuccessfully = $zip->open($zipFileFullPath, ZipArchive::CREATE);
if ($zipCreateSuccessfully !== true) {
self::debugApi( 'Document with id '.$page_id.' broken. Can not create a zip file. Error code: '.$zipCreateSuccessfully);
return false;
} else {
self::debugApi('zip file as object create successfully');
}
/* some code here */
self::debugApi('begin add file index to zip');
$zip->addFromString('index', (string) json_encode($index));
self::debugApi('Zip status: ' . $zip->getStatusString() . '. Num files: ' . $zip->numFiles);
self::debugApi('trying to close zip an object and create a file');
if ($zip->close()){
self::debugApi('zip file as file create successfully');
} else {
self::debugApi('((ERROR)) the zip file after closing the object was not found. Path for search: ' . $zipFileFullPath);
self::debugApi('call error_get_last: ' . print_r(error_get_last(),1) );
return false;
}
/* call import method */
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question