Skip to content

Commit f82593d

Browse files
Quppacmb69
authored andcommitted
Fix GH-7815: php_uname doesn't recognise latest Windows versions
We check `dwBuildNumber` to determine newer Windows versions. Closes GH-7816.
1 parent 187e011 commit f82593d

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ PHP NEWS
5959

6060
- Standard:
6161
. Fixed bug GH-7748 (gethostbyaddr outputs binary string). (cmb)
62+
. Fixed bug GH-7815 (php_uname doesn't recognise latest Windows versions).
63+
(David Warner)
6264

6365
02 Dec 2021, PHP 8.1.1
6466

ext/standard/info.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,34 @@ char* php_get_windows_name()
268268

269269
if (VER_PLATFORM_WIN32_NT==osvi.dwPlatformId && osvi.dwMajorVersion >= 10) {
270270
if (osvi.dwMajorVersion == 10) {
271-
if( osvi.dwMinorVersion == 0 ) {
272-
if( osvi.wProductType == VER_NT_WORKSTATION ) {
273-
major = "Windows 10";
271+
if (osvi.dwMinorVersion == 0) {
272+
if (osvi.wProductType == VER_NT_WORKSTATION) {
273+
if (osvi.dwBuildNumber >= 22000) {
274+
major = "Windows 11";
275+
} else {
276+
major = "Windows 10";
277+
}
274278
} else {
275-
major = "Windows Server 2016";
279+
if (osvi.dwBuildNumber >= 20348) {
280+
major = "Windows Server 2022";
281+
} else if (osvi.dwBuildNumber >= 19042) {
282+
major = "Windows Server, version 20H2";
283+
} else if (osvi.dwBuildNumber >= 19041) {
284+
major = "Windows Server, version 2004";
285+
} else if (osvi.dwBuildNumber >= 18363) {
286+
major = "Windows Server, version 1909";
287+
} else if (osvi.dwBuildNumber >= 18362) {
288+
major = "Windows Server, version 1903";
289+
} else if (osvi.dwBuildNumber >= 17763) {
290+
// could also be Windows Server, version 1809, but there's no easy way to tell
291+
major = "Windows Server 2019";
292+
} else if (osvi.dwBuildNumber >= 17134) {
293+
major = "Windows Server, version 1803";
294+
} else if (osvi.dwBuildNumber >= 16299) {
295+
major = "Windows Server, version 1709";
296+
} else {
297+
major = "Windows Server 2016";
298+
}
276299
}
277300
}
278301
}

0 commit comments

Comments
 (0)