Skip to content

Commit ed998f8

Browse files
committed
Fix #50678 files extracted by ZipArchive class lost their original modified time
1 parent 373a6d8 commit ed998f8

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,7 @@ PHP NEWS
146146
. ZipArchive::status and ZipArchive::statusSys properties and
147147
ZipArchive::getStatusString() method stay valid after the archive
148148
is closed. (Remi)
149+
. Fixed bug #50678 (files extracted by ZipArchive class lost their
150+
original modified time). (Remi)
149151

150152
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>

UPGRADING

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ PHP 8.0 UPGRADE NOTES
449449
. ZipArchive::addEmptyDir, ZipArchive::addFile and aZipArchive::addFromString
450450
methods have a new "flags" argument. This allow to manage name encoding
451451
(ZipArchive::FL_ENC_*) and entry replacement (ZipArchive::FL_OVERWRITE)
452+
. ZipArchive::extractTo now restore file modification time.
452453

453454
========================================
454455
6. New Functions

ext/zip/php_zip.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
258258
php_stream_write(stream, b, n);
259259
}
260260

261+
if (stream->wrapper->wops->stream_metadata) {
262+
struct utimbuf ut;
263+
264+
ut.modtime = ut.actime = sb.mtime;
265+
stream->wrapper->wops->stream_metadata(stream->wrapper, fullpath, PHP_STREAM_META_TOUCH, &ut, NULL);
266+
}
267+
261268
php_stream_close(stream);
262269
n = zip_fclose(zf);
263270

0 commit comments

Comments
 (0)