Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Is it possible to use wb instead of wb+ fopen mode in openToFile() in AbstractWriter in order to use compress.zlib:// ? #881

Open
cmanley opened this issue Mar 30, 2022 · 5 comments

Comments

@cmanley
Copy link

cmanley commented Mar 30, 2022

If I try to write to a compressed CSV file, then I get an exception using the file wrapper compress.zlib://

I think it has to do with the seekable file mode used here:
$this->filePointer = $this->globalFunctionsHelper->fopen($this->outputFilePath, 'wb+');

Simply removing the + from the file mode seems to solve the problem but I'm not sure if box/spout needs it somewhere for something.

B.t.w. this is the exception and errors I get when I open a file with a compress.zlib wrapper using the latest v2 release:

PHP Warning:  fopen(compress.zlib://art.csv.gz): failed to open stream: operation failed in lib/box/spout/src/Spout/Common/Helper/GlobalFunctionsHelper.php on line 25
PHP Fatal error:  Uncaught Box\Spout\Common\Exception\IOException: File pointer has not be opened in lib/box/spout/src/Spout/Writer/AbstractWriter.php:175
@cmanley cmanley changed the title Is it possible to use a non-seekable file mode in openToFile() in AbstractWriter in order to use compress.zlib:// ? Is it possible to use wb instead of wb+ fopen mode in openToFile() in AbstractWriter in order to use compress.zlib:// ? Mar 30, 2022
@Slamdunk
Copy link

Fix merged in openspout/openspout#66 and released in openspout:v3.7.4

@cmanley
Copy link
Author

cmanley commented Mar 31, 2022 via email

@Slamdunk
Copy link

Slamdunk commented Mar 31, 2022

There's no branch 2.x in the community fork I'm maintaining at https://github.com/openspout/openspout, sorry

@Slamdunk
Copy link

If you need a backport, I suggest leveraging https://github.com/cweagans/composer-patches

@cmanley
Copy link
Author

cmanley commented Mar 31, 2022

Alright thanks. I only just noticed that the patch was in openspout. That's new to me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants