Skip to content

Commit 3775d47

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78220: Can't access OneDrive folder
2 parents 86d751f + 5e19f1d commit 3775d47

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? ????, PHP 7.4.0beta3
44

55
- Core:
6+
. Fixed bug #78220 (Can't access OneDrive folder). (cmb, ab)
67
. Fixed bug #78396 (Second file_put_contents in Shutdown hangs script).
78
(Nikita)
89
. Fixed bug #78406 (Broken file includes with user-defined stream filters).

Zend/zend_virtual_cwd.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ static cwd_state main_cwd_state; /* True global */
9393
#include <unistd.h>
9494
#else
9595
#include <direct.h>
96+
#include "zend_globals.h"
97+
#include "zend_globals_macros.h"
9698
#endif
9799

98100
#define CWD_STATE_COPY(d, s) \
@@ -608,6 +610,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
608610
tmp = do_alloca(len+1, use_heap);
609611
memcpy(tmp, path, len+1);
610612

613+
retry:
611614
if(save &&
612615
!(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') &&
613616
(dataw.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
@@ -655,7 +658,21 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
655658
return (size_t)-1;
656659
}
657660
if(!DeviceIoControl(hLink, FSCTL_GET_REPARSE_POINT, NULL, 0, pbuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &retlength, NULL)) {
661+
BY_HANDLE_FILE_INFORMATION fileInformation;
662+
658663
free_alloca(pbuffer, use_heap_large);
664+
if ((dataw.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
665+
(dataw.dwReserved0 & ~IO_REPARSE_TAG_CLOUD_MASK) == IO_REPARSE_TAG_CLOUD &&
666+
EG(windows_version_info).dwMajorVersion >= 10 &&
667+
EG(windows_version_info).dwMinorVersion == 0 &&
668+
EG(windows_version_info).dwBuildNumber >= 18362 &&
669+
GetFileInformationByHandle(hLink, &fileInformation) &&
670+
!(fileInformation.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
671+
dataw.dwFileAttributes = fileInformation.dwFileAttributes;
672+
CloseHandle(hLink);
673+
(*ll)--;
674+
goto retry;
675+
}
659676
free_alloca(tmp, use_heap);
660677
CloseHandle(hLink);
661678
FREE_PATHW()
@@ -735,8 +752,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
735752
}
736753
else if (pbuffer->ReparseTag == IO_REPARSE_TAG_DEDUP ||
737754
/* Starting with 1709. */
738-
(pbuffer->ReparseTag & IO_REPARSE_TAG_CLOUD_MASK) != 0 && 0x90001018L != pbuffer->ReparseTag ||
739-
IO_REPARSE_TAG_CLOUD == pbuffer->ReparseTag ||
755+
(pbuffer->ReparseTag & ~IO_REPARSE_TAG_CLOUD_MASK) == IO_REPARSE_TAG_CLOUD ||
740756
IO_REPARSE_TAG_ONEDRIVE == pbuffer->ReparseTag) {
741757
isabsolute = 1;
742758
substitutename = malloc((len + 1) * sizeof(char));

ext/standard/tests/dir/bug78220.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #78220 (Can't access OneDrive folder)
3+
--SKIPIF--
4+
<?php
5+
if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only");
6+
?>
7+
--FILE--
8+
<?php
9+
$onedrive_dirs = array_unique([getenv('OneDrive'), getenv('OneDriveCommercial')]);
10+
foreach ($onedrive_dirs as $dir) {
11+
if ($dir && scandir($dir) === FALSE) {
12+
echo "can't scan $dir\n";
13+
}
14+
}
15+
?>
16+
--EXPECT--

0 commit comments

Comments
 (0)