Problem/Motivation

PHP addFile function in zipArchive takes the second argument
'entryname' and use it to name file in the archive instead of file path. Drupal core/lib/Drupal/Core/Archiver/Zip.php add functionon on the other hand takes only one argument filepath and therefore use it to name files in archive.

Steps to reproduce

Use drupal plugin.manager.archiver and add function to create the zip archive. When you open the archive you will file path used to name the file inside the archive.
e.g /var/www/html/web/sites/default/files/yourfilename

Proposed resolution

Pass the second optional argument 'entryname' to override the filename in the archive https://www.php.net/manual/en/ziparchive.addfile.php

Remaining tasks

Testing

Issue fork drupal-3312312

Command icon 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

majid.ali created an issue. See original summary.

majid.ali’s picture

Title: Add second argument "entryname" to core/lib/Drupal/Core/Archiver/Zip.php add function to be used as local file name in zip instead of file path. » Add second argument "entryname" to core/lib/Drupal/Core/Archiver/Zip.php add function to be used as local file name in zip archive instead of file path.
majid.ali’s picture

StatusFileSize
new1.3 KB
heni_deepak’s picture

@majid.ali
can it's need to update related class Tar?

Method 'Drupal\Core\Archiver\Tar::add()' is not compatible with method 
'Drupal\Core\Archiver\ArchiverInterface::add()'.intelephense(1038)
heni_deepak’s picture

Status: Active » Needs work
heni_deepak’s picture

StatusFileSize
new1.74 KB

reload #3 patch

ravi.shankar’s picture

Status: Needs work » Needs review
StatusFileSize
new1.77 KB
new806 bytes

Addressed Drupal CS issues of patch #6.

cilefen’s picture

Version: 9.5.x-dev » 10.1.x-dev
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

#7 had some CI failures

Also at this time we will need a D10 version
Tagging for tests also.

_utsavsharma’s picture

StatusFileSize
new2.51 KB
new2.41 KB

Patch for 10.1.x.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

majid.ali’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

This one still appears to need test coverage please

longwave’s picture

The Archiver subsystem is deprecated and will be removed in 12.0.0, not sure this is worth it?