[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
franck-paul opened this issue Mar 3, 2023 · 8 comments

Comments

@franck-paul
Copy link

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

@franck-paul
Copy link
Author

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

@nielsdos
Copy link
Member
nielsdos commented Mar 3, 2023

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

nielsdos added a commit to nielsdos/php-src that referenced this issue Mar 3, 2023
…not keep files metadata (datetime)

Due to an incorrect check, the datetime was never actually set.
To test this we need to write the file using phar, but read the file
using a different method to not get a cached, or a value that's been
transformed twice and is therefore accidentally correct.
nielsdos added a commit that referenced this issue Mar 4, 2023
* PHP-8.1:
  Fix GH-10766: PharData archive created with Phar::Zip format does not keep files metadata (datetime)
nielsdos added a commit that referenced this issue Mar 4, 2023
* PHP-8.2:
  Fix GH-10766: PharData archive created with Phar::Zip format does not keep files metadata (datetime)
@franck-paul
Copy link
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?

@nielsdos
Copy link
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.

@franck-paul
Copy link
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:

@nielsdos
Copy link
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.

@franck-paul
Copy link
Author

You're welcome and thanks for confirming!

@danepowell
Copy link

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
Projects
None yet
Development

No branches or pull requests

4 participants
@franck-paul @danepowell @nielsdos and others