$archiver_manager = \Drupal::service('plugin.manager.archiver');
$zip_archive = $archiver_manager->getInstance(['filepath' => './testzip.zip']);

I execute the above code using drush scr command but it does not create a new ZIP file for me.
Shows: Cannot open <em class="placeholder">./testzip.zip</em>

/core/lib/Drupal/Core/Archiver/Zip.php class constructor states that If the file does not yet exist, it will be created if appropriate. But it does not does so under any circumstance.

Example code for ZipArchive given in PHP.net makes use of the ZipArchive::CREATE flag when opening a file, so that a new file is created if it does not exist.

Probably we need to do the same.

CommentFileSizeAuthor
#2 3143267-2.patch591 bytesvivek panicker

Comments

Vivek Panicker created an issue. See original summary.

vivek panicker’s picture

StatusFileSize
new591 bytes
vivek panicker’s picture

Assigned: vivek panicker » Unassigned
Status: Active » Needs review
vivek panicker’s picture

The patch seems to be fine.
Can't understand why it fails to apply.

kristen pol’s picture

Version: 9.0.x-dev » 9.1.x-dev
Status: Needs review » Needs work
Issue tags: +Needs reroll

Not sure why it's not applied but I verified it does not apply cleanly to 9.1.x so moving back to needs work.

kristen pol’s picture

Issue tags: +Bug Smash Initiative, +Novice
cilefen’s picture

I think this is a duplicate of #2850794: Unable to open Zip archive using ArchiverZip that has had a lot of work done.

andypost’s picture

cilefen’s picture

Status: Needs work » Closed (duplicate)