$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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3143267-2.patch | 591 bytes | vivek panicker |
Comments
Comment #2
vivek panicker commentedComment #3
vivek panicker commentedComment #4
vivek panicker commentedThe patch seems to be fine.
Can't understand why it fails to apply.
Comment #5
kristen polNot sure why it's not applied but I verified it does not apply cleanly to 9.1.x so moving back to needs work.
Comment #6
kristen polComment #7
cilefen commentedI think this is a duplicate of #2850794: Unable to open Zip archive using ArchiverZip that has had a lot of work done.
Comment #8
andypostIt also could be caused by missing zip php extension
Comment #9
cilefen commented