Skip to content

PharData archive created with Phar::Zip format does not keep files metadata (datetime) #10766

Closed

Description

@franck-paul

Description

Having a file created this day (2023-03-03) named myfile.txt in /tmp directory.

The following code:

<?php
$a = new \PharData('/tmp/archive.zip', \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS, null, \Phar::ZIP);
$a->addFile('/tmp/myfile.txt', 'name');

$b = new \PharData('/tmp/archive.tar', \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS, null, \Phar::TAR);
$b->addFile('/tmp/myfile.txt', 'name');

Resulted in this output (uncompress '/tmp/archive.zip' archive):

name 1980-01-01

But I expected this output instead (uncompress '/tmp/archive.tar' archive):

name 2023-03-03

PHP Version

PHP 8.2.0

Operating System

MacOS 13.2

Activity

  1. franck-paul commented on Mar 3, 2023

    @franck-paul
    Author

    This issue is also valid for PHP 7.4, PHP 8.0 and PHP 8.1

  2. ndossche commented on Mar 3, 2023

    @ndossche
    Member

    I can confirm this on 8.1+ and I'll now try to debug this issue.

  3. added 3 commits that reference this issue on Mar 3, 2023
    bea9baf
    e633be3
    d8294f2
  4. added a commit that references this issue on Mar 4, 2023
    43c71df
  5. franck-paul commented on Mar 17, 2023

    @franck-paul
    Author

    I see that PHP 8.2.4 and 8.1.17 have been released but without any fix about this issue, do you why?

  6. ndossche commented on Mar 17, 2023

    @ndossche
    Member

    The fix is applied to those versions.
    Does the original code in your opening post still reproduce the issue for you? I just tried your code from the opening post and it works on my machine.

  7. franck-paul commented on Mar 17, 2023

    @franck-paul
    Author

    Oh ok, I have not test it yet, but seeing the 8.2.4 and 8.1.17 branches on this very repository does not show any modification in file ext\phar\zip.c it's why I asked this.

    And your modification is:

  8. ndossche commented on Mar 17, 2023

    @ndossche
    Member

    @franck-paul Sorry I just realised something, I was testing on the latest 8.1 development build...
    The fix is indeed not in 8.1.17 and 8.2.4, because the fix was created when the development cycle of those versions were already ended. So the fix will be available in the next release of 8.1 and 8.2.

  9. franck-paul commented on Mar 17, 2023

    @franck-paul
    Author

    You're welcome and thanks for confirming!

  10. danepowell commented on Oct 27, 2023

    @danepowell

    I suspect that fixing this revealed a deeper bug in the timezone handling: #12532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions