Doc #80940 [PATCH]: async function addFromString work incorrect
From: skuratovichalex@gmail.com Date: Wed, 07 Apr 2021 19:08:11 +0000 Subject: Doc #80940 [PATCH]: async function addFromString work incorrect References: 1 Groups: php.doc.bugs Request: Send a blank email to doc-bugs+get-18695@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80940&edit=1
ID: 80940
Patch added by: skuratovichalex@gmail.com
Reported by: skuratovichalex at gmail dot com
Summary: async function addFromString work incorrect
Status: Open
Type: Documentation Problem
Package: Zip Related
Operating System: Debian 9
PHP Version: 7.4.16
Block user comment: N
Private report: N
New Comment:
The following patch has been added/updated:
Patch Name: async-add-fromstring-wrong
Revision: 1617822491
URL: https://bugs.php.net/patch-display.php?bug=80940&patch=async-add-fromstring-wrong&revision=1617822491
Previous Comments:
------------------------------------------------------------------------
[2021-04-07 19:00:44] skuratovichalex at gmail dot com
Description:
------------
The essence of the problem is that when using the ZipArchive methods asynchronously, at the output I
get the required archive, but only with the last processed file within the framework of asynchrony
(To be more precise, the archive contains N / t files, where N is the total files to be added , t is
the number of processing threads)
PS-The initial presence of the archive does not change the situation.
Example: (6 files)
https://drive.google.com/file/d/1BAHn4iSElaADwfxQ_3_ZaTOmPKvggwH6/view?usp=sharing
Test script:
---------------
//one stream
$za = new \ZipArchive();
($za->open($zipFile, \ZipArchive::CREATE) !== TRUE) {
throw new \Exception('Cannot create a zip file');
}
$arFile = $dir . '/' . $newFileName . '.json';
$result = $za->addFromString($arFile, $stringData);
$error = $za->getStatusString( );
$arIndex = $za->locateName($arFile);
$arInfo = $za->statName($arFile);
$closeResult = $za->close();
var_dump($error, $arIndex, $arInfo, $closeResult);
Expected result:
----------------
file2
file1
file3
file4
string(8) "No error"
int(0)
array(8) {
["name"]=>
string(17) "/order/file2.json"
["index"]=>
int(0)
["crc"]=>
int(0)
["size"]=>
int(811758)
["mtime"]=>
int(1617821517)
["comp_size"]=>
int(811758)
["comp_method"]=>
int(0)
["encryption_method"]=>
int(0)
}
bool(true)
string(8) "No error"
int(0)
array(8) {
["name"]=>
string(17) "/order/file3.json"
["index"]=>
int(0)
["crc"]=>
int(0)
["size"]=>
int(811758)
["mtime"]=>
int(1617821517)
["comp_size"]=>
int(811758)
["comp_method"]=>
int(0)
["encryption_method"]=>
int(0)
}
bool(true)
string(8) "No error"
int(0)
array(8) {
["name"]=>
string(17) "/order/file4.json"
["index"]=>
int(0)
["crc"]=>
int(0)
["size"]=>
int(811758)
["mtime"]=>
int(1617821517)
["comp_size"]=>
int(811758)
["comp_method"]=>
int(0)
["encryption_method"]=>
int(0)
}
bool(true)
string(8) "No error"
int(0)
array(8) {
["name"]=>
string(17) "/order/file1.json"
["index"]=>
int(0)
["crc"]=>
int(0)
["size"]=>
int(811758)
["mtime"]=>
int(1617821517)
["comp_size"]=>
int(811758)
["comp_method"]=>
int(0)
["encryption_method"]=>
int(0)
}
bool(true)
Actual result:
--------------
4 JSON-files in ZIP-archive.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80940&edit=1
Thread (9 messages)
- Doc #80940 [PATCH]: async function addFromString work incorrect
- Doc #80940 [Com]: async function addFromString work incorrect
- Doc #80940 [Opn->Ver]: async function addFromString work incorrect
- Doc #80940 [Com]: async function addFromString work incorrect
- Doc #80940 [Com]: async function addFromString work incorrect
- Doc #80940 [Com]: async function addFromString work incorrect
- Doc #80940 [Com]: async function addFromString work incorrect
- Doc #80940 [Com]: async function addFromString work incorrect
| « previous | php.doc.bugs (#18695) | next » |
|---|