[OJS 3.3.0-13] Button “Download All Files” in submission doesn’t work

Describe the issue or problem
We have the same problem solved here, our IT made the change suggested by @asmecher but the download all button still make a 0 byte zip file

Steps I took leading up to the issue
Here what our IT did:
cat = print the file
-n = with line numbers
grep import = where you find the word import
immagine

What application are you using?
OJS 3.3.0-13

Can someone help?
Thanks and best regards
Stefano

1 Like

Hi @bolelligallevi,

Can you check your PHP error log? It might identify a problem like a missing PHP dependency.

Regards,
Alec Smecher
Public Knowledge Project Team

Hello,
this is the apache errors log when you try to download a zip package:

[Fri Mar 03 17:00:54.678093 2023] [proxy_fcgi:error] [pid 16316] (32)Broken pipe: [client XX.XXX.XX.XX:XXXX] AH01075: Error dispatching request to : (passing brigade to output filters)

[Fri Mar 03 17:00:54.870282 2023] [proxy_fcgi:error] [pid 16174] [client XX.XX.XX.XXX:XXXXX] AH01071: Got error 'PHP message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::addFile(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 39PHP
 message: PHP Warning:  ZipArchive::close(): Invalid or uninitialized Zip object in /my-ojs-www-path/lib/pkp/classes/file/FileArchive.inc.php on line 41', referer: https://myojs/index.php/myjournal/workflow/index/12345/1

NB: php7.3-zip is installed

Thanks,
Alfredo

@Alfredo_Cosco, is /tmp your system’s temporary directory (and should PHP be able to create files there)?

Regards,
Alec Smecher
Public Knowledge Project Team

yes /tmp is the system temp dir and PHP is able to write in

Hi @Alfredo_Cosco,

Hmm, I can’t think of any other requirements for that feature. I’m afraid you’ll have to inspect the code directly and see where it’s failing; I wonder whether something internal to your server is missing/badly configured.

Before digging further, ensure that clicking each file individually results in a successful download; if these files are missing it could cause ZipArchive to complain.

You could try running a PHP test script outside of OJS to verify that the ZipArchive tools are working. See the examples here:

https://www.php.net/manual/en/zip.examples.php

Make sure you use a sample archive inside /tmp/ so that it’s comparable to OJS.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec,

ensure that clicking each file individually results in a successful download

Yes, single files are downloaded

I used an easy script like this:

<?php

$zip = new ZipArchive();
$filename = "/tmp/test112.zip";

if ($zip->open($filename, ZipArchive::CREATE)!==TRUE) {
    exit("cannot open <$filename>\n");
}

$zip->addFile("testfilephp.txt");
$zip->addFile("testfilephp2.txt");

echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";
$zip->close();
?>

And it works well, creates the zip file in /tmp dir, that hasn’t writing limits.

Anyway the problem appeared after the upgrade to 3.3.0-13 and the server is the same.

No one experienced a similar issue?

Hi @Alfredo_Cosco,

Are you trying the test script via web-based invocation, or from the command line? These might have different file permission requirements, and different PHP configuration files.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

This topic was automatically closed after 11 days. New replies are no longer allowed.

Hello,
continuing investigating about:

@asmecher I changed the script and put It under the document root, it work, I download a regualr zip file.

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$zip = new ZipArchive();

echo "Start<br>";

$filename = "test112.zip";
$filepath = "/tmp/";
$archive = $filepath.$filename;

echo $archive."<br>";

if ($zip->open($archive, ZipArchive::CREATE)!==TRUE) {
    exit("cannot open <$archive>\n");
}

$zip->addFile("testfilephp.txt");
$zip->addFile("testfilephp2.txt");

echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";

$zip->close();

echo "<br>zipclose<br>";

header("Content-type: application/zip"); 
header("Content-Disposition: attachment; filename=$filename");
header("Content-length: " . filesize($filename));
header("Pragma: no-cache"); 
header("Expires: 0"); 
readfile("$archive");

echo "end";

exit;

?>

Hi @Alfredo_Cosco,

Are you trying the test script via web-based invocation, or from the command line?

Regards,
Alec Smecher
Public Knowledge Project Team

Hello @asmecher
web based invocation, I put it in the site webroot then I call the path in the browser.

Hi @Alfredo_Cosco,

The “download all” link is implemented in lib/pkp/controllers/api/file/FileApiHandler.inc.php in the downloadAllFiles function, which in turn uses the lib/pkp/classes/file/FileArchive.inc.php class. I’d suggest using some error_log calls in FileArchive.inc.php to see if you can identify where the process is going awry.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Hello @asmecher ,
my colleague @sourcedump solved the problem by adding:

@unlink($archivePath);

at line 38 del file ‘lib/pkp/classes/file/FileArchive.inc.php’.

Hi @Alfredo_Cosco,

Ah, that was they key! I was able to identify the difference between your system and mine: apparently yours has a newer version of libzip that does not accept an empty file as a valid archive as noted in the PHP ZipArchive documentation.

I’ve filed and fixed this here:

Thanks for tracking this down!

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like