Skip to content

Commit 221345a

Browse files
committed
Fix #77594: ob_tidyhandler is never reset
We reset to original INI value on request shutdown. Closes GH-6425.
1 parent ed949a1 commit 221345a

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ PHP NEWS
99
(cmb)
1010
. Fixed bug #72964 (White space not unfolded for CC/Bcc headers). (cmb)
1111

12+
- Tidy:
13+
. Fixed bug #77594 (ob_tidyhandler is never reset). (cmb)
14+
1215
26 Nov 2020, PHP 7.4.13
1316

1417
- Core:

ext/tidy/tests/bug77594.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #77594 (ob_tidyhandler is never reset)
3+
--DESCRIPTION--
4+
Test is useful only with --repeat 2 (or more)
5+
--SKIPIF--
6+
<?php
7+
if (!extension_loaded('tidy')) die('skip tidy extension not available');
8+
?>
9+
--FILE--
10+
<?php
11+
ob_start('ob_tidyhandler');
12+
var_dump(ob_end_clean());
13+
?>
14+
--EXPECT--
15+
bool(true)

ext/tidy/tidy.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ static int php_tidy_output_handler(void **nothing, php_output_context *output_co
240240
static PHP_MINIT_FUNCTION(tidy);
241241
static PHP_MSHUTDOWN_FUNCTION(tidy);
242242
static PHP_RINIT_FUNCTION(tidy);
243+
static PHP_RSHUTDOWN_FUNCTION(tidy);
243244
static PHP_MINFO_FUNCTION(tidy);
244245

245246
static PHP_FUNCTION(tidy_getopt);
@@ -500,7 +501,7 @@ zend_module_entry tidy_module_entry = {
500501
PHP_MINIT(tidy),
501502
PHP_MSHUTDOWN(tidy),
502503
PHP_RINIT(tidy),
503-
NULL,
504+
PHP_RSHUTDOWN(tidy),
504505
PHP_MINFO(tidy),
505506
PHP_TIDY_VERSION,
506507
PHP_MODULE_GLOBALS(tidy),
@@ -1106,6 +1107,13 @@ static PHP_RINIT_FUNCTION(tidy)
11061107
return SUCCESS;
11071108
}
11081109

1110+
static PHP_RSHUTDOWN_FUNCTION(tidy)
1111+
{
1112+
TG(clean_output) = INI_ORIG_BOOL("tidy.clean_output");
1113+
1114+
return SUCCESS;
1115+
}
1116+
11091117
static PHP_MSHUTDOWN_FUNCTION(tidy)
11101118
{
11111119
UNREGISTER_INI_ENTRIES();

0 commit comments

Comments
 (0)