Skip to content

Fix GH-17951: Addition of max_memory_limit INI #18011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Prev Previous commit
Changed fatals to warnings during startup
  • Loading branch information
frederikpyt committed Apr 22, 2025
commit 1d49976296d96d2002437b751a5f453f785905ce
4 changes: 2 additions & 2 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static PHP_INI_MH(OnChangeMemoryLimit)
if (PG(max_memory_limit) != -1) {
if (value == -1) {
zend_error(
stage == ZEND_INI_STAGE_STARTUP ? E_ERROR : E_WARNING,
E_WARNING,
"Failed to set memory_limit to unlimited. memory_limit (currently: " ZEND_LONG_FMT " bytes) cannot be set to unlimited if max_memory_limit (" ZEND_LONG_FMT " bytes) is not unlimited",
PG(memory_limit),
PG(max_memory_limit)
Expand All @@ -338,7 +338,7 @@ static PHP_INI_MH(OnChangeMemoryLimit)

if (value > PG(max_memory_limit)) {
zend_error(
stage == ZEND_INI_STAGE_STARTUP ? E_ERROR : E_WARNING,
E_WARNING,
"Failed to set memory_limit to %zd bytes. memory_limit (currently: " ZEND_LONG_FMT " bytes) cannot exceed max_memory_limit (" ZEND_LONG_FMT " bytes)",
value,
PG(memory_limit),
Expand Down
2 changes: 1 addition & 1 deletion tests/basic/gh17951_ini_parse_4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ max_memory_limit=128M
echo ini_get('max_memory_limit') . PHP_EOL;
echo ini_get('memory_limit') . PHP_EOL;
--EXPECTF--
Fatal error: Failed to set memory_limit to unlimited. memory_limit (currently: %d bytes) cannot be set to unlimited if max_memory_limit (%d bytes) is not unlimited in %s
Warning: Failed to set memory_limit to unlimited. memory_limit (currently: %d bytes) cannot be set to unlimited if max_memory_limit (%d bytes) is not unlimited in %s
128M
128M
2 changes: 1 addition & 1 deletion tests/basic/gh17951_ini_parse_5.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ max_memory_limit=128M
echo ini_get('max_memory_limit') . PHP_EOL;
echo ini_get('memory_limit') . PHP_EOL;
--EXPECTF--
Fatal error: Failed to set memory_limit to %d bytes. memory_limit (currently: %d bytes) cannot exceed max_memory_limit (%d bytes) in %s
Warning: Failed to set memory_limit to %d bytes. memory_limit (currently: %d bytes) cannot exceed max_memory_limit (%d bytes) in %s
128M
128M
Loading