At work, I was tasked with porting some cronjobs from an old server (php 5.2.x) to a new server (php 5.3.x) and ran into a weird issue. The code to be ported was explicitly unlinking a file which was just added to the ZipArchive, in efforts to keep the filesystem clean, and ran fine on php 5.2.x, but when I ported the same code over to php 5.3.x I couldn’t get the zip file to write in it’s entirety.

Below is the code snippet:

$zip = new ZipArchive;

$zip->open('/path/to/', ZipArchive::OVERWRITE);

foreach ($files as $file) {

    $zip->addFile((string $file));

    // This is the offending line
    unlink((string) $file);

After I commented out the unlink, everything worked as expected. Thought I would bring it up in case anyone else faces the same situation.