From f739e9d3c1ee0c8b9693550f5a0cde078ffab3ce Mon Sep 17 00:00:00 2001 From: lamentxu <1372449351@qq.com> Date: Fri, 1 May 2026 16:35:02 +0800 Subject: [PATCH 1/4] initial --- .github/scripts/windows/check-snmp-ready.ps1 | 46 ++++++++++++++++++++ .github/scripts/windows/test_task.bat | 7 ++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/scripts/windows/check-snmp-ready.ps1 diff --git a/.github/scripts/windows/check-snmp-ready.ps1 b/.github/scripts/windows/check-snmp-ready.ps1 new file mode 100644 index 000000000000..d19ea71369a9 --- /dev/null +++ b/.github/scripts/windows/check-snmp-ready.ps1 @@ -0,0 +1,46 @@ +param( + [Parameter(Mandatory = $true)] + [string]$PhpBuildDir +) + +$php = Join-Path $PhpBuildDir 'php.exe' +$snmpExtension = Join-Path $PhpBuildDir 'php_snmp.dll' + +if (-not (Test-Path $php)) { + Write-Error "Could not find $php" + exit 1 +} + +if (-not (Test-Path $snmpExtension)) { + Write-Error "Could not find $snmpExtension" + exit 1 +} + +$phpCode = @' +snmp_set_valueretrieval(SNMP_VALUE_PLAIN); +$oid = '.1.3.6.1.2.1.1.1.0'; +if (@snmpget('127.0.0.1', 'public', $oid, 1000000, 0) === false) { + exit(1); +} +if (@snmp3_get('127.0.0.1', 'adminMD5AES', 'authPriv', 'MD5', 'test1234', 'AES', 'test1234', $oid, 1000000, 0) === false) { + exit(1); +} +'@ + +for ($i = 0; $i -lt 30; $i++) { + & $php -n "-dextension_dir=$PhpBuildDir" -dextension=php_snmp.dll -r $phpCode *> $null + if ($LASTEXITCODE -eq 0) { + exit 0 + } + + if (-not (Get-Process -Name snmpd -ErrorAction SilentlyContinue)) { + Write-Output 'snmpd exited before the readiness check succeeded' + exit 1 + } + + Start-Sleep -Seconds 1 +} + +Write-Output 'snmpd did not become ready within 30 seconds' + +exit 1 diff --git a/.github/scripts/windows/test_task.bat b/.github/scripts/windows/test_task.bat index 4ce2bd96ce66..79e2172f3f2a 100644 --- a/.github/scripts/windows/test_task.bat +++ b/.github/scripts/windows/test_task.bat @@ -109,7 +109,8 @@ popd rem prepare for snmp set MIBDIRS=%DEPS_DIR%\share\mibs sed -i "s/exec HexTest .*/exec HexTest cscript\.exe \/nologo %GITHUB_WORKSPACE:\=\/%\/ext\/snmp\/tests\/bigtest\.js/g" %GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf -start %DEPS_DIR%\bin\snmpd.exe -C -c %GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf -Ln +powershell -NoProfile -Command "Start-Process -FilePath (Join-Path $env:DEPS_DIR 'bin\snmpd.exe') -ArgumentList '-C','-c',(Join-Path $env:GITHUB_WORKSPACE 'ext\snmp\tests\snmpd.conf'),'-Ln'" +if %errorlevel% neq 0 exit /b 3 set PHP_BUILD_DIR=%PHP_BUILD_OBJ_DIR%\Release if "%THREAD_SAFE%" equ "1" set PHP_BUILD_DIR=%PHP_BUILD_DIR%_TS @@ -147,6 +148,10 @@ copy /-y %DEPS_DIR%\bin\*.dll %PHP_BUILD_DIR%\* if "%ASAN%" equ "1" set ASAN_OPTS=--asan +rem wait until snmpd is fully ready to serve v2c and v3/authPriv requests +powershell -NoProfile -File .github\scripts\windows\check-snmp-ready.ps1 -PhpBuildDir %PHP_BUILD_DIR% +if %errorlevel% neq 0 exit /b 3 + mkdir c:\tests_tmp nmake test TESTS="%OPCACHE_OPTS% -g FAIL,BORK,LEAK,XLEAK %ASAN_OPTS% --no-progress -q --offline --show-diff --show-slow 1000 --set-timeout 120 --temp-source c:\tests_tmp --temp-target c:\tests_tmp %PARALLEL%" From 7265f577030919bd7ab0063a04e8bdd6af695634 Mon Sep 17 00:00:00 2001 From: lamentxu <1372449351@qq.com> Date: Fri, 1 May 2026 16:53:02 +0800 Subject: [PATCH 2/4] use bat instead of ps1 --- .github/scripts/windows/check-snmp-ready.bat | 46 ++++++++++++++++++++ .github/scripts/windows/check-snmp-ready.ps1 | 46 -------------------- .github/scripts/windows/test_task.bat | 4 +- 3 files changed, 48 insertions(+), 48 deletions(-) create mode 100644 .github/scripts/windows/check-snmp-ready.bat delete mode 100644 .github/scripts/windows/check-snmp-ready.ps1 diff --git a/.github/scripts/windows/check-snmp-ready.bat b/.github/scripts/windows/check-snmp-ready.bat new file mode 100644 index 000000000000..ce2082d9edb0 --- /dev/null +++ b/.github/scripts/windows/check-snmp-ready.bat @@ -0,0 +1,46 @@ +@echo off +setlocal + +set "PHP_BUILD_DIR=%~1" +if "%PHP_BUILD_DIR%"=="" ( + echo Usage: %~nx0 PHP_BUILD_DIR + exit /b 1 +) + +set "PHP_EXE=%PHP_BUILD_DIR%\php.exe" +set "PHP_SNMP_DLL=%PHP_BUILD_DIR%\php_snmp.dll" +set "PHP_CODE=snmp_set_valueretrieval(SNMP_VALUE_PLAIN); $oid='.1.3.6.1.2.1.1.1.0'; if (@snmpget('127.0.0.1', 'public', $oid, 1000000, 0) === false) exit(1); if (@snmp3_get('127.0.0.1', 'adminMD5AES', 'authPriv', 'MD5', 'test1234', 'AES', 'test1234', $oid, 1000000, 0) === false) exit(1);" + +if not exist "%PHP_EXE%" ( + echo Could not find "%PHP_EXE%" + exit /b 1 +) + +if not exist "%PHP_SNMP_DLL%" ( + echo Could not find "%PHP_SNMP_DLL%" + exit /b 1 +) + +for /l %%i in (1,1,30) do ( + call :probe + if not errorlevel 1 goto ready + tasklist /fi "IMAGENAME eq snmpd.exe" | findstr /i "snmpd.exe" >nul + if errorlevel 1 ( + echo snmpd exited before the readiness check succeeded + goto fail + ) + timeout /t 1 /nobreak >nul +) + +echo snmpd did not become ready within 30 seconds +goto fail + +:ready +exit /b 0 + +:fail +exit /b 1 + +:probe +"%PHP_EXE%" -n -dextension_dir=%PHP_BUILD_DIR% -dextension=php_snmp.dll -r "%PHP_CODE%" >nul 2>&1 +exit /b %errorlevel% diff --git a/.github/scripts/windows/check-snmp-ready.ps1 b/.github/scripts/windows/check-snmp-ready.ps1 deleted file mode 100644 index d19ea71369a9..000000000000 --- a/.github/scripts/windows/check-snmp-ready.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -param( - [Parameter(Mandatory = $true)] - [string]$PhpBuildDir -) - -$php = Join-Path $PhpBuildDir 'php.exe' -$snmpExtension = Join-Path $PhpBuildDir 'php_snmp.dll' - -if (-not (Test-Path $php)) { - Write-Error "Could not find $php" - exit 1 -} - -if (-not (Test-Path $snmpExtension)) { - Write-Error "Could not find $snmpExtension" - exit 1 -} - -$phpCode = @' -snmp_set_valueretrieval(SNMP_VALUE_PLAIN); -$oid = '.1.3.6.1.2.1.1.1.0'; -if (@snmpget('127.0.0.1', 'public', $oid, 1000000, 0) === false) { - exit(1); -} -if (@snmp3_get('127.0.0.1', 'adminMD5AES', 'authPriv', 'MD5', 'test1234', 'AES', 'test1234', $oid, 1000000, 0) === false) { - exit(1); -} -'@ - -for ($i = 0; $i -lt 30; $i++) { - & $php -n "-dextension_dir=$PhpBuildDir" -dextension=php_snmp.dll -r $phpCode *> $null - if ($LASTEXITCODE -eq 0) { - exit 0 - } - - if (-not (Get-Process -Name snmpd -ErrorAction SilentlyContinue)) { - Write-Output 'snmpd exited before the readiness check succeeded' - exit 1 - } - - Start-Sleep -Seconds 1 -} - -Write-Output 'snmpd did not become ready within 30 seconds' - -exit 1 diff --git a/.github/scripts/windows/test_task.bat b/.github/scripts/windows/test_task.bat index 79e2172f3f2a..d9a9d13a8b9f 100644 --- a/.github/scripts/windows/test_task.bat +++ b/.github/scripts/windows/test_task.bat @@ -109,7 +109,7 @@ popd rem prepare for snmp set MIBDIRS=%DEPS_DIR%\share\mibs sed -i "s/exec HexTest .*/exec HexTest cscript\.exe \/nologo %GITHUB_WORKSPACE:\=\/%\/ext\/snmp\/tests\/bigtest\.js/g" %GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf -powershell -NoProfile -Command "Start-Process -FilePath (Join-Path $env:DEPS_DIR 'bin\snmpd.exe') -ArgumentList '-C','-c',(Join-Path $env:GITHUB_WORKSPACE 'ext\snmp\tests\snmpd.conf'),'-Ln'" +start "" /b "%DEPS_DIR%\bin\snmpd.exe" -C -c "%GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf" -Ln if %errorlevel% neq 0 exit /b 3 set PHP_BUILD_DIR=%PHP_BUILD_OBJ_DIR%\Release @@ -149,7 +149,7 @@ copy /-y %DEPS_DIR%\bin\*.dll %PHP_BUILD_DIR%\* if "%ASAN%" equ "1" set ASAN_OPTS=--asan rem wait until snmpd is fully ready to serve v2c and v3/authPriv requests -powershell -NoProfile -File .github\scripts\windows\check-snmp-ready.ps1 -PhpBuildDir %PHP_BUILD_DIR% +.github\scripts\windows\check-snmp-ready.bat %PHP_BUILD_DIR% if %errorlevel% neq 0 exit /b 3 mkdir c:\tests_tmp From 7474936df6edb164e566f9a001af6361da3ffb09 Mon Sep 17 00:00:00 2001 From: lamentxu <1372449351@qq.com> Date: Sun, 3 May 2026 00:41:09 +0800 Subject: [PATCH 3/4] init --- NEWS | 2 ++ UPGRADING | 5 +++++ ext/gmp/gmp.c | 9 +++++---- ext/gmp/tests/overloading_with_float_fractional.phpt | 6 ++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 3144cdf88c59..42f3189ed0e5 100644 --- a/NEWS +++ b/NEWS @@ -51,6 +51,8 @@ PHP NEWS . gmp_fact() reject values larger than unsigned long. (David Carlier) . gmp_pow/binomial/root/rootrem and shift/pow operators reject values larger than unsigned long. (David Carlier) + . GMP exponentiation and shift operators now emit a deprecation warning + when converting a float right operand to int loses precision. (Weilin Du) - Hash: . Upgrade xxHash to 0.8.2. (timwolla) diff --git a/UPGRADING b/UPGRADING index 6777820642f6..5cc924d80aeb 100644 --- a/UPGRADING +++ b/UPGRADING @@ -166,6 +166,11 @@ PHP 8.6 UPGRADE NOTES is no longer maintained. RFC: https://wiki.php.net/rfc/eol-oniguruma +- GMP: + . The shift (<<, >>) and exponentiation (**) operators on GMP objects now + emit a deprecation warning when converting a float right operand to int + loses precision. + ======================================== 5. Changed Functions ======================================== diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 6fa1fe7dd899..ce975757247a 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -332,14 +332,15 @@ static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_val if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) { if (UNEXPECTED(!IS_GMP(op2))) { - // For PHP 8.3 and up use zend_try_get_long() switch (Z_TYPE_P(op2)) { - case IS_DOUBLE: - shift = zval_get_long(op2); - if (UNEXPECTED(EG(exception))) { + case IS_DOUBLE: { + bool failed; + shift = zval_try_get_long(op2, &failed); + if (UNEXPECTED(failed)) { return FAILURE; } break; + } case IS_STRING: if (is_numeric_str_function(Z_STR_P(op2), &shift, NULL) != IS_LONG) { goto valueof_op_failure; diff --git a/ext/gmp/tests/overloading_with_float_fractional.phpt b/ext/gmp/tests/overloading_with_float_fractional.phpt index fc078eeec3e9..a86356a9dd54 100644 --- a/ext/gmp/tests/overloading_with_float_fractional.phpt +++ b/ext/gmp/tests/overloading_with_float_fractional.phpt @@ -100,6 +100,8 @@ object(GMP)#2 (1) { ["num"]=> string(1) "0" } + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(69) "150130937545296572356771972164254457814047970568738777235893533016064" @@ -122,10 +124,14 @@ object(GMP)#2 (1) { ["num"]=> string(1) "0" } + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(15) "184717953466368" } + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(1) "0" From e77d738ecb0d925616b98593bb9a701ea61fa9a8 Mon Sep 17 00:00:00 2001 From: lamentxu <1372449351@qq.com> Date: Sun, 3 May 2026 00:42:16 +0800 Subject: [PATCH 4/4] [skip ci] Revert "init" (I push it to the wrong branch) This reverts commit 7474936df6edb164e566f9a001af6361da3ffb09. --- NEWS | 2 -- UPGRADING | 5 ----- ext/gmp/gmp.c | 9 ++++----- ext/gmp/tests/overloading_with_float_fractional.phpt | 6 ------ 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/NEWS b/NEWS index 42f3189ed0e5..3144cdf88c59 100644 --- a/NEWS +++ b/NEWS @@ -51,8 +51,6 @@ PHP NEWS . gmp_fact() reject values larger than unsigned long. (David Carlier) . gmp_pow/binomial/root/rootrem and shift/pow operators reject values larger than unsigned long. (David Carlier) - . GMP exponentiation and shift operators now emit a deprecation warning - when converting a float right operand to int loses precision. (Weilin Du) - Hash: . Upgrade xxHash to 0.8.2. (timwolla) diff --git a/UPGRADING b/UPGRADING index 5cc924d80aeb..6777820642f6 100644 --- a/UPGRADING +++ b/UPGRADING @@ -166,11 +166,6 @@ PHP 8.6 UPGRADE NOTES is no longer maintained. RFC: https://wiki.php.net/rfc/eol-oniguruma -- GMP: - . The shift (<<, >>) and exponentiation (**) operators on GMP objects now - emit a deprecation warning when converting a float right operand to int - loses precision. - ======================================== 5. Changed Functions ======================================== diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index ce975757247a..6fa1fe7dd899 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -332,15 +332,14 @@ static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_val if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) { if (UNEXPECTED(!IS_GMP(op2))) { + // For PHP 8.3 and up use zend_try_get_long() switch (Z_TYPE_P(op2)) { - case IS_DOUBLE: { - bool failed; - shift = zval_try_get_long(op2, &failed); - if (UNEXPECTED(failed)) { + case IS_DOUBLE: + shift = zval_get_long(op2); + if (UNEXPECTED(EG(exception))) { return FAILURE; } break; - } case IS_STRING: if (is_numeric_str_function(Z_STR_P(op2), &shift, NULL) != IS_LONG) { goto valueof_op_failure; diff --git a/ext/gmp/tests/overloading_with_float_fractional.phpt b/ext/gmp/tests/overloading_with_float_fractional.phpt index a86356a9dd54..fc078eeec3e9 100644 --- a/ext/gmp/tests/overloading_with_float_fractional.phpt +++ b/ext/gmp/tests/overloading_with_float_fractional.phpt @@ -100,8 +100,6 @@ object(GMP)#2 (1) { ["num"]=> string(1) "0" } - -Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(69) "150130937545296572356771972164254457814047970568738777235893533016064" @@ -124,14 +122,10 @@ object(GMP)#2 (1) { ["num"]=> string(1) "0" } - -Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(15) "184717953466368" } - -Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(1) "0"