php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #61272
Patch pass-cleaned-output-to-callback revision 2012-06-08 07:51 UTC by casper at langemeijer dot eu

Patch pass-cleaned-output-to-callback for Output Control Bug #61272

Patch version 2012-06-08 07:51 UTC

Return to Bug #61272 | Download this patch
Patch Revisions:

Developer: casper@langemeijer.eu

diff --git a/main/output.c b/main/output.c
index d4eaa67..6a612d3 100644
--- a/main/output.c
+++ b/main/output.c
@@ -297,9 +297,9 @@ PHPAPI int php_output_clean(TSRMLS_D)
 	php_output_context context;
 
 	if (OG(active) && (OG(active)->flags & PHP_OUTPUT_HANDLER_CLEANABLE)) {
-		OG(active)->buffer.used = 0;
 		php_output_context_init(&context, PHP_OUTPUT_HANDLER_CLEAN TSRMLS_CC);
 		php_output_handler_op(OG(active), &context);
+		OG(active)->buffer.used = 0;
 		php_output_context_dtor(&context);
 		return SUCCESS;
 	}
@@ -1226,9 +1226,12 @@ static inline int php_output_stack_pop(int flags TSRMLS_DC)
 			/* signal that we're cleaning up */
 			if (flags & PHP_OUTPUT_POP_DISCARD) {
 				context.op |= PHP_OUTPUT_HANDLER_CLEAN;
-				orphan->buffer.used = 0;
 			}
 			php_output_handler_op(orphan, &context);
+
+			if (flags & PHP_OUTPUT_POP_DISCARD) {
+				orphan->buffer.used = 0;
+			}
 		}
 
 		/* pop it off the stack */
diff --git a/tests/output/ob_017.phpt b/tests/output/ob_017.phpt
index 070df60..517fafe 100644
--- a/tests/output/ob_017.phpt
+++ b/tests/output/ob_017.phpt
@@ -27,8 +27,8 @@ Array
     [0] => 1: yes
     [1] => 4: !
 
-    [2] => 2: 
+    [2] => 2: no
     [3] => 0: yes!
 
-    [4] => 10: 
+    [4] => 10: no
 )
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC