Problem/Motivation
When you're trying to unpack Zip archive using 'plugin.manager.archiver' service, it will throw this error if PHP Zip extension is not installed.
Steps to reproduce
$archiver_manager = \Drupal::service('plugin.manager.archiver');
$archiver_manager->getInstance(['filepath' => $path_to_zip]);
Since the Drupal CI environment does have the PHP-zip extension installed (See CI-output snippet below), this is untestable (at least without jumping through hoops)
00:00:49.786 As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.
00:00:49.786 This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
00:00:49.786 Installing 'unzip' may remediate them.
Proposed resolution
@larowlan suggests in comment #10 two approaches for the issue:
1) Either the ArchiveInterface plugin system is extented to allow plugins to declare their required extensions
or
2) We make core require the zip extension, this would require patching both system_requirements and composer.json
In #4 @Niklan tried solution #2, but commented in #7:
Even after creating a patch that adds requirement to the extension in comment #4, the error still appearing.
As far as I (=Spokje) can tell an "actual" solution is being done in #2850794: Unable to open Zip archive using ArchiverZip.
This issue is merely to prevent/soften the error, by telling Drupal it hasn't got the capabilities to handle ZIP-files when there's no PHP-Zip extension present.
This is done by implementing the system_archiver_info_alter-hook.
Also, as per @longwave's suggestion in comment #16, we add a suggest entry to composer.json to suggest the user to install/enable the PHP-Zip extension.
Remaining tasks
1. Create patch/MR.
2. Review.
3. Commit.
5. Let unicorns and rainbows rule the universe once more.
| Comment | File | Size | Author |
|---|---|---|---|
| #48 | 3163123-10.0-48.patch | 1.79 KB | spokje |
| #47 | 3163123-10.x-47.patch | 1.79 KB | spokje |
Issue fork drupal-3163123
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mxmilkiib commentedThat was me needing to install the php zip dependency!
Comment #3
niklanHm, It's actually a core bug.
The Drupal Core doesn't require
ext-zipincomposer.jsonfile. This leads to this problem.Comment #4
niklanComment #5
niklanI believe the System requirements page also needs to be updated to explicitly tells that Drupal needs PHP Zip extension.
Comment #6
niklanComment #7
niklanThings going a bit complicated.
PHP 7.4.8, Zip and ZLib extensions enabled. Still got this error. So this is not the only requirements missing problem.
Comment #9
andypostComment #10
larowlanThere are two approaches here:
- either the ArchiverInterface plugin system is extended to allow plugins to declare their required extensions and this is used when creating an instance
- OR -
- we make core require the zip extension, this would require patching both system_requirements and composer.json.
Comment #11
andypostAt least patch to prevent this
Comment #12
andypostI was wrong
Comment #13
andypost11 is the valid patch
Comment #14
andypostSince php 5.5 better to use full class name
Comment #15
hardik_patel_12 commentedLast patch failed to apply for 9.0.x , uploading new patch for 9.0.x kindly review.
Comment #16
longwaveWe could add a
suggestentry to composer.json as well?Comment #17
quietone commentedCan we update the IS? Would be nice to know what the resolution is and what are the remaining tasks.
And #16 needs to be addressed.
Comment #18
anmolgoyal74 commentedAddressed #16.
Added suggest in composer.json
Comment #20
anmolgoyal74 commentedComment #21
anmolgoyal74 commentedComment #23
anmolgoyal74 commentedUpdated hash.
Comment #25
mxmilkiib commentedAny chance the patch could be updated please? It fails to apply on 9.1.3.
Comment #26
quietone commentedStill needs an issue summary update. In order to review the patch and check that it is doing what is planned the IS needs to have, at least, a proposed resolution section completed.
Comment #27
guilhermevp commentedComment #28
quietone commented@guilhermevp, thank you very much.
I read the issue and found that the question in #16 has not been answered. Setting to NW for that and the fact that the patch needs a reroll.
Comment #30
guilhermevp commentedRe-rolled patch #23
Comment #31
spokjeComment #32
spokjeNot quite sure why this issue is still stuck on
9.1.x, updated Version to9.3.x.Since only the creator of a MR can change the branch-to-merge-to I'm opening a new MR based on
9.3.x.Comment #34
spokjeMade 4 changes:
1) Moved the
suggestbit fromcomposer.jsontocore/composer.json. This because it seemed to me that all the requiring of PHP extensions is done over there.2) There's nocore/composer.lock, but even if there was, adding asuggestdoesn't show up in the correspondingcomposer.lockfile.2) Did a
composer update drupal/coreto pull in our changedcore/composer.json.3) The correct capitalisation in the
system_archiver_info_alter-hook isZip.4) Reworded the
suggestbit incore/composer.json.Comment #35
spokjeUpdated the IS with what I believe is going on.
Comment #36
spokjeComment #37
quietone commented#16 is now addressed and the solution here is one of the two suggested in #10. Unfortunately, the MR needs an update.
Comment #38
spokjeThanks @quietone.
9.3.xinto the MR.composer update drupal/coreto pull in our changedcore/composer.json.Test currently running.
Comment #39
spokjeComment #40
spokjeRerolled against the latest
9.3.xComment #43
andypostIt makes sense to improve as drupal-CI runners mentions in every CI-run
Comment #45
spokjeComment #46
nod_need a reroll
Comment #47
spokjeComment #48
spokjeComment #49
nod_thanks :)
Feeling luck so RTBC
Comment #50
catchMakes sense to not add this if it's not available, and to add the extension to suggestions, but the patch doesn't apply on 10.1
Comment #53
longwave#47 applied to 10.1.x, and #48 to 10.0.x; committed to both branches. Thanks!