php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26862 ob_flush() doesn't output last two chars
Submitted: 2004-01-10 11:42 UTC Modified: 2004-02-11 11:54 UTC
From: nunoplopes at sapo dot pt Assigned:
Status: Closed Package: Output Control
PHP Version: 4CVS, 5CVS OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nunoplopes at sapo dot pt
New email:
PHP Version: OS:

 

 [2004-01-10 11:42 UTC] nunoplopes at sapo dot pt
Description:
------------
When using the given code, ob_flush() doesn't output all the buffer. When using ob_get_flush() it works as expected.

Reproduce code:
---------------
<?php
session_start();
output_add_rewrite_var('var', 'value');

echo '<a href="file.php">link</a>';

ob_flush();

output_reset_rewrite_vars();
echo '<a href="file.php">link</a>';
?>

Expected result:
----------------
<a href="file.php?SESSID=xxx&var=value">link</a><a href="file.php">link</a>

Actual result:
--------------
<a href="file.php?SESSID=xxx&var=value">link</<a href="file.php">link</a>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-22 10:48 UTC] nunoplopes at sapo dot pt
I've checked the sources and if you changed the implementation of ob_flush everything works:

use this:
php_end_ob_buffer(1, 0 TSRMLS_CC);
instead of:
php_end_ob_buffer(1, 1 TSRMLS_CC);

So, the error is in just_flush in php_end_ob_buffer().
 [2004-02-09 20:26 UTC] scottmacvicar at ntlworld dot com
I think i've tracked this one down to the URL parser, it happens when the argument do_flush is set to false for url_adapt_ext (url_scanner_ex.c line 837) this is because it only expects to do the re-write at the final flush.

I modified what was passed in to accept the final flush or a flush halfway through the script execution.

Patch
---
diff -u url_scanner_ex.c url_scanner_ex.c.patched
--- url_scanner_ex.c    2004-02-10 01:29:05.000000000 +0000
+++ url_scanner_ex.c.patched    2004-02-10 01:30:51.000000000 +0000
@@ -918,7 +918,8 @@
        size_t len;
 
     if (BG(url_adapt_state_ex).url_app.len != 0) {
-        *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode&PHP_OUTPUT_HANDLER_END ? 1 : 0) TSRMLS_CC);
+        *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) ((mode & PHP_OUTPUT_HANDLER_CONT) || (mode 
+& PHP_OUTPUT_HANDLER_END) ? 1 : 0) TSRMLS_CC);
                if (sizeof(uint) < sizeof(size_t)) {
                        if (len > UINT_MAX)
                                len = UINT_MAX;
 [2004-02-10 12:39 UTC] nunoplopes at sapo dot pt
this patch works for me
 [2004-02-11 11:54 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2011-05-23 12:42 UTC] mike@php.net
Automatic comment from SVN on behalf of mike
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=311348
Log: Fix Bug #54727, a re-incarnation of #26862
 [2011-05-24 07:06 UTC] mike@php.net
Automatic comment from SVN on behalf of mike
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=311375
Log: MFH: Fix Bug #54727, a re-incarnation of #26862
 [2012-04-18 09:50 UTC] laruence@php.net
Automatic comment on behalf of mike
Revision: http://git.php.net/?p=php-src.git;a=commit;h=327a87fdd9e7946d31d9f3176e8f3dac5449e7a3
Log: Fix Bug #54727, a re-incarnation of #26862
 [2012-07-24 23:41 UTC] rasmus@php.net
Automatic comment on behalf of mike
Revision: http://git.php.net/?p=php-src.git;a=commit;h=327a87fdd9e7946d31d9f3176e8f3dac5449e7a3
Log: Fix Bug #54727, a re-incarnation of #26862
 [2013-11-17 09:38 UTC] laruence@php.net
Automatic comment on behalf of mike
Revision: http://git.php.net/?p=php-src.git;a=commit;h=327a87fdd9e7946d31d9f3176e8f3dac5449e7a3
Log: Fix Bug #54727, a re-incarnation of #26862
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 08:01:29 2024 UTC