Skip to content

Deprecate disabling report_memleaks INI directive #19481

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 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PHP NEWS
triggers "Constant already defined" warning). (ilutov)
. Fixed bug GH-19476 (pipe operator fails to correctly handle returning
by reference). (alexandre-daubois)
. The report_memleaks INI directive has been deprecated. (alexandre-daubois)

- ODBC:
. Remove ODBCVER and assume ODBC 3.5. (Calvin Buckley)
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ PHP 8.5 UPGRADE NOTES
. Returning null from __debugInfo() has been deprecated.
Return an empty array instead.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_debuginfo_returning_null
. The report_memleaks INI directive has been deprecated.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_report_memleaks_ini_directive

- Curl:
. The curl_close() function has been deprecated, as CurlHandle objects are
Expand Down
15 changes: 14 additions & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,19 @@ static PHP_INI_MH(OnUpdateInputEncoding)
}
/* }}} */

static PHP_INI_MH(OnUpdateReportMemleaks)
{
bool *p = (bool *) ZEND_INI_GET_ADDR();
bool new_bool_value = zend_ini_parse_bool(new_value);

if (!new_bool_value) {
php_error_docref(NULL, E_DEPRECATED, "Directive 'report_memleaks' is deprecated");
}

*p = new_bool_value;
return SUCCESS;
}

/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateOutputEncoding)
{
Expand Down Expand Up @@ -801,7 +814,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("log_errors", "0", PHP_INI_ALL, OnUpdateBool, log_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("ignore_repeated_errors", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("ignore_repeated_source", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_source, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("report_memleaks", "1", PHP_INI_ALL, OnUpdateBool, report_memleaks, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("report_memleaks", "1", PHP_INI_ALL, OnUpdateReportMemleaks, report_memleaks, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("report_zend_debug", "0", PHP_INI_ALL, OnUpdateBool, report_zend_debug, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLong, output_buffering, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateString, output_handler, php_core_globals, core_globals)
Expand Down
3 changes: 2 additions & 1 deletion php.ini-development
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,12 @@ ignore_repeated_errors = Off
; https://php.net/ignore-repeated-source
ignore_repeated_source = Off

; Use of this INI entry is deprecated, it will be removed in PHP 9.0.
; If this parameter is set to Off, then memory leaks will not be shown (on
; stdout or in the log). This is only effective in a debug compile, and if
; error reporting includes E_WARNING in the allowed list
; https://php.net/report-memleaks
report_memleaks = On
;report_memleaks = On

; This setting is off by default.
;report_zend_debug = 0
Expand Down
3 changes: 2 additions & 1 deletion php.ini-production
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,12 @@ ignore_repeated_errors = Off
; https://php.net/ignore-repeated-source
ignore_repeated_source = Off

; Use of this INI entry is deprecated, it will be removed in PHP 9.0.
; If this parameter is set to Off, then memory leaks will not be shown (on
; stdout or in the log). This is only effective in a debug compile, and if
; error reporting includes E_WARNING in the allowed list
; https://php.net/report-memleaks
report_memleaks = On
;report_memleaks = On

; This setting is off by default.
;report_zend_debug = 0
Expand Down
1 change: 0 additions & 1 deletion run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ function main(): void
'log_errors=0',
'html_errors=0',
'track_errors=0',
'report_memleaks=1',
'report_zend_debug=0',
'docref_root=',
'docref_ext=.html',
Expand Down
11 changes: 11 additions & 0 deletions tests/basic/ini_directive_deprecated_report_memleaks.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Deprecated INI directive report_memleaks warning
--INI--
report_memleaks=0
--FILE--
<?php
echo "Testing deprecated report_memleaks INI directive.\n";
?>
--EXPECT--
Deprecated: PHP Startup: Directive 'report_memleaks' is deprecated in Unknown on line 0
Testing deprecated report_memleaks INI directive.