I am trying to export my data to a gedcom file into a zip archive („manage family trees“ or „clipping cart“).
This fails with the following error:
Could not open zip archive at:/tmp/webtrees-zip-ZLgSb1, error: 19 …/vendor/league/flysystem-ziparchive/src/ZipArchiveAdapter.php:86
The web server just writes a „500“ into the access log.
When I search for the file in the filesystem of my Linux server, I find it within a private /tmp folder (systemd) of my Apache web server. But the file is empty (size of 0 bytes).
If I disable the private temp option for httpd within the systemd configuration, the result is the same. The empty file can be found directly under /tmp.
selinux is not enabled.
I‘m running PHP with fpm, so the file is created as the linux User owning the webtrees installation and not the user running the web server. Could that be a problem?
I tried to debug this by editing the file ExportGedcomClient.php where I changed $temp_zip_file to be a file within the data-directory of webtrees (line 108). This seemed to work better, but the resulting zip file on the web server was not complete and the browser only showed a white page instead of letting me saving a zip file to my local disk. But this seems to be another error (or just a wrong way to debug ;) ).
This one works as expected. A file "FOOUpKZIA" is created within the private temp folder of the web server and contains "schreiben in Temporärdatei". Owner is the linux user running the php-script.
So generally tempnam() seems to work on my system.
The second problem:
If I change line 108 to be a fixed name the zip file is created and also "filled".
$temp_zip_file = 'data/tmp/zipexport.zip';
With no media files included (just the compressed gedcom-file) the browser lets me download the zip archive which contains valid data. The contained gedcom seems to be complete.
If I add media files, the zip archive is created, the .ged file and 7 media files are put into the archive. File size is approximately 70MB. Unzipping the archive directly on the server (with unzip) works like a charm, all 8 files are extracted without error. The browser only shows a white page instead of letting me download the file.
Today I changed "memory_limit = 128M" to "512M" within php.ini. Then I was I able to download the zip archive (367MB), and it seems to contain all required media files.
So this part of the problem seems to be solved (even if I am surprised that the complete zip file has to fit in php memory, but I don't have much experience in php programming).
But the temp file creation/usage does not work correctly (at least in my environment).
Do you have an idea what I can try to fix it?