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 CreditAttribution: 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-zip
incomposer.json
file. 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 CreditAttribution: Hardik_Patel_12 at QED42 for Drupal India Association commentedLast patch failed to apply for 9.0.x , uploading new patch for 9.0.x kindly review.
Comment #16
longwaveWe could add a
suggest
entry to composer.json as well?Comment #17
quietone CreditAttribution: quietone as a volunteer 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 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedAddressed #16.
Added suggest in composer.json
Comment #20
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedComment #21
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedComment #23
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedUpdated hash.
Comment #25
mxmilkiib CreditAttribution: mxmilkiib commentedAny chance the patch could be updated please? It fails to apply on 9.1.3.
Comment #26
quietone CreditAttribution: quietone as a volunteer 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 CreditAttribution: guilhermevp at CI&T commentedComment #28
quietone CreditAttribution: quietone as a volunteer 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 CreditAttribution: guilhermevp at CI&T 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
suggest
bit fromcomposer.json
tocore/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 asuggest
doesn't show up in the correspondingcomposer.lock
file.2) Did a
composer update drupal/core
to pull in our changedcore/composer.json
.3) The correct capitalisation in the
system_archiver_info_alter
-hook isZip
.4) Reworded the
suggest
bit incore/composer.json
.Comment #35
SpokjeUpdated the IS with what I believe is going on.
Comment #36
SpokjeComment #37
quietone CreditAttribution: quietone as a volunteer 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.x
into the MR.composer update drupal/core
to pull in our changedcore/composer.json
.Test currently running.
Comment #39
SpokjeComment #40
SpokjeRerolled against the latest
9.3.x
Comment #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!