Skip to content

Commit 5e5b7cb

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix #78241: touch() does not handle dates after 2038 in PHP 64-bit
2 parents 9ad09ce + 44c8b74 commit 5e5b7cb

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ PHP NEWS
2121
. Fixed #78192 (SegFault when reuse statement after schema has changed).
2222
(Vincent Quatrevieux)
2323

24+
- Standard:
25+
. Fixed #78241 (touch() does not handle dates after 2038 in PHP 64-bit). (cmb)
26+
2427
04 Jul 2019, PHP 7.3.7
2528

2629
- Core:

TSRM/tsrm_win32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static zend_always_inline void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {
770770
// Note that LONGLONG is a 64-bit value
771771
LONGLONG ll;
772772

773-
ll = Int32x32To64(t, 10000000) + 116444736000000000;
773+
ll = t * 10000000 + 116444736000000000;
774774
pft->dwLowDateTime = (DWORD)ll;
775775
pft->dwHighDateTime = ll >> 32;
776776
}

ext/standard/tests/file/bug78241.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #78241 (touch() does not handle dates after 2038 in PHP 64-bit)
3+
--SKIPIF--
4+
<?php
5+
if (substr(PHP_OS, 0, 3) != 'WIN') die('skip this test is for Windows platforms only');
6+
if (PHP_INT_SIZE != 8) die('skip this test is for 64bit platforms only');
7+
?>
8+
--INI--
9+
date.timezone=UTC
10+
--FILE--
11+
<?php
12+
$filename = __DIR__ . '/bug78241.txt';
13+
for ($i = 2037; $i <= 2040; $i++) {
14+
$t = mktime(1, 1 , 1, 1, 1, $i);
15+
echo 'Date: '.date('D, d M Y H:i:s', $t), PHP_EOL;
16+
touch($filename, $t);
17+
clearstatcache(true, $filename);
18+
$file = filemtime($filename);
19+
echo 'File: '.date('D, d M Y H:i:s', $file), PHP_EOL, PHP_EOL;
20+
}
21+
?>
22+
--EXPECT--
23+
Date: Thu, 01 Jan 2037 01:01:01
24+
File: Thu, 01 Jan 2037 01:01:01
25+
26+
Date: Fri, 01 Jan 2038 01:01:01
27+
File: Fri, 01 Jan 2038 01:01:01
28+
29+
Date: Sat, 01 Jan 2039 01:01:01
30+
File: Sat, 01 Jan 2039 01:01:01
31+
32+
Date: Sun, 01 Jan 2040 01:01:01
33+
File: Sun, 01 Jan 2040 01:01:01

0 commit comments

Comments
 (0)