]> granicus.if.org Git - php/commitdiff
Fix #50678 files extracted by ZipArchive class lost their original modified time
authorRemi Collet <remi@php.net>
Mon, 9 Mar 2020 06:09:50 +0000 (07:09 +0100)
committerRemi Collet <remi@php.net>
Mon, 9 Mar 2020 06:09:50 +0000 (07:09 +0100)
NEWS
UPGRADING
ext/zip/php_zip.c

diff --git a/NEWS b/NEWS
index 5dca4c47709848bbe678893a2146abf20a2b8ecf..2c30043c71d1f61ef8b6441918d8584ec95d8c9b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -146,5 +146,7 @@ PHP                                                                        NEWS
   . ZipArchive::status and ZipArchive::statusSys properties and
     ZipArchive::getStatusString() method stay valid after the archive
     is closed. (Remi)
+  . Fixed bug #50678 (files extracted by ZipArchive class lost their
+    original modified time). (Remi)
 
 <<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>
index 4eebd4e49efd285b081a00ee1b9b443f41c4507e..41a72c280dad16ccbaff7763b9e99e026c26b7df 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -449,6 +449,7 @@ PHP 8.0 UPGRADE NOTES
  . ZipArchive::addEmptyDir, ZipArchive::addFile and aZipArchive::addFromString
    methods have a new "flags" argument. This allow to manage name encoding
    (ZipArchive::FL_ENC_*) and entry replacement (ZipArchive::FL_OVERWRITE)
+ . ZipArchive::extractTo now restore file modification time.
 
 ========================================
 6. New Functions
index 898627960242a3080659c0e257b4bd380ec1a534..e7ca9cb4775a0257ff707c4b7503abfb47338ee6 100644 (file)
@@ -258,6 +258,13 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
                php_stream_write(stream, b, n);
        }
 
+       if (stream->wrapper->wops->stream_metadata) {
+               struct utimbuf ut;
+
+               ut.modtime = ut.actime = sb.mtime;
+               stream->wrapper->wops->stream_metadata(stream->wrapper, fullpath, PHP_STREAM_META_TOUCH, &ut, NULL);
+       }
+
        php_stream_close(stream);
        n = zip_fclose(zf);