# function ob_gzhandler is missed in 5.4

- Thread: https://externals.io/message/56312
- Original archive: https://news-web.php.net/php.internals/56312
- Started by Laruence on 2011-11-13T15:11:02+00:00
- Messages: 20
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #56312 — Laruence — 2011-11-13T15:11:02+00:00

URL: https://externals.io/message/56312#56312

Hi:

this revisioin remove the ob_* functions:
http://svn.php.net/viewvc?view=revision&revision=299980

is this intentional?  if yes, I think this will become a doc problem.

thanks

-- 
Laruence  Xinchen Hui
http://www.laruence.com/

---

## #56313 — Reindl Harald — 2011-11-13T15:26:01+00:00

URL: https://externals.io/message/56312#56313 · In reply to: #56312

Am 13.11.2011 16:11, schrieb Laruence:
> Hi:
> 
> this revisioin remove the ob_* functions:
> http://svn.php.net/viewvc?view=revision&revision=299980
> 
> is this intentional?  if yes, I think this will become a doc problem

i think / hope this is an accident

if the ob_functions(9 are replaced in any way this is not a doc-problem

it would be a major BC-break and destroy all my work of the last 10 years
rely on `ob_start()`, `ob_get_contents()`, `ob_get_clean()` and the fact
that multiple `ob_start()` can work inside another one as example to
include module-files using normal output-functions, buffer the output
and replace a palceholder in a template with the buffer while we are
in another template (site-template, list-templates, item-templates)

---

## #56314 — Rasmus Lerdorf — 2011-11-13T15:38:22+00:00

URL: https://externals.io/message/56312#56314 · In reply to: #56313

All the ob_* tests are still in 5.4 and they all pass, so no, these
functions have not been removed.


> 
> 
> Am 13.11.2011 16:11, schrieb Laruence:
> > […]
> 
> i think / hope this is an accident
> 
> if the ob_functions(9 are replaced in any way this is not a
> doc-problem
> 
> it would be a major BC-break and destroy all my work of the last 10
> years rely on `ob_start()`, `ob_get_contents()`, `ob_get_clean()` and the
> fact that multiple `ob_start()` can work inside another one as
> example to include module-files using normal output-functions,
> buffer the output and replace a palceholder in a template with the
> buffer while we are in another template (site-template,
> list-templates, item-templates)

---

## #56315 — Ferenc Kovacs — 2011-11-13T15:47:57+00:00

URL: https://externals.io/message/56312#56315 · In reply to: #56313

On Sun, Nov 13, 2011 at 4:26 PM, Reindl Harald <h.reindl@thelounge.net>wrote:

>
>
> Am 13.11.2011 16:11, schrieb Laruence:
> > […]
>
> i think / hope this is an accident
>
> if the ob_functions(9 are replaced in any way this is not a doc-problem
>
> it would be a major BC-break and destroy all my work of the last 10 years
> rely on `ob_start()`, `ob_get_contents()`, `ob_get_clean()` and the fact
> that multiple `ob_start()` can work inside another one as example to
> include module-files using normal output-functions, buffer the output
> and replace a palceholder in a template with the buffer while we are
> in another template (site-template, list-templates, item-templates)
>
>
I see these functions present in the current trunk:

ob_functions in current trunk/5.4 branch:

tyrael@chronos:~/checkouts/php-src/trunk$ ./sapi/cli/php -r
'var_dump(get_defined_functions());'|grep 'ob_'
    string(8) "ob_start"
    string(8) "ob_flush"
    string(8) "ob_clean"
    string(12) "ob_end_flush"
    string(12) "ob_end_clean"
    string(12) "ob_get_flush"
    string(12) "ob_get_clean"
    string(13) "ob_get_length"
    string(12) "ob_get_level"
    string(13) "ob_get_status"
    string(15) "ob_get_contents"
    string(17) "ob_implicit_flush"
    string(16) "ob_list_handlers"

tyrael@chronos:~/checkouts/php-src/branches/PHP_5_4$ ./sapi/cli/php -r
'var_dump(get_defined_functions());'|grep 'ob_'
    string(8) "ob_start"
    string(8) "ob_flush"
    string(8) "ob_clean"
    string(12) "ob_end_flush"
    string(12) "ob_end_clean"
    string(12) "ob_get_flush"
    string(12) "ob_get_clean"
    string(13) "ob_get_length"
    string(12) "ob_get_level"
    string(13) "ob_get_status"
    string(15) "ob_get_contents"
    string(17) "ob_implicit_flush"
    string(16) "ob_list_handlers"

ob functions in 5.3:

tyrael@chronos:~/checkouts/php-src/branches/PHP_5_4$ php -r
'var_dump(get_defined_functions());'|grep 'ob_'
    string(12) "ob_gzhandler"
    string(16) "ob_iconv_handler"
    string(8) "ob_start"
    string(8) "ob_flush"
    string(8) "ob_clean"
    string(12) "ob_end_flush"
    string(12) "ob_end_clean"
    string(12) "ob_get_flush"
    string(12) "ob_get_clean"
    string(13) "ob_get_length"
    string(12) "ob_get_level"
    string(13) "ob_get_status"
    string(15) "ob_get_contents"
    string(17) "ob_implicit_flush"
    string(16) "ob_list_handlers"


as you can see, there is 2 functions gone in 5.4/trunk:
    string(12) "ob_gzhandler"
    string(16) "ob_iconv_handler"

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #56316 — Reindl Harald — 2011-11-13T15:51:20+00:00

URL: https://externals.io/message/56312#56316 · In reply to: #56315

Am 13.11.2011 16:47, schrieb Ferenc Kovacs:
> as you can see, there is 2 functions gone in 5.4/trunk:
>     string(12) "ob_gzhandler"
>     string(16) "ob_iconv_handler"

thank your for confirming that

i only liked to get sure what happens early enough
the two missing are not soo bad but AFAIK also used from many
applications while i personally prerfer mod_deflate

---

## #56317 — Laruence — 2011-11-13T15:52:25+00:00

URL: https://externals.io/message/56312#56317 · In reply to: #56313

Hi:
   my mistake in the word usage, I mean ob_gzhandler missd,,

   not ob_*,,

  sorry

thanks


>
>
> Am 13.11.2011 16:11, schrieb Laruence:
> > […]
>
> i think / hope this is an accident
>
> if the ob_functions(9 are replaced in any way this is not a doc-problem
>
> it would be a major BC-break and destroy all my work of the last 10 years
> rely on `ob_start()`, `ob_get_contents()`, `ob_get_clean()` and the fact
> that multiple `ob_start()` can work inside another one as example to
> include module-files using normal output-functions, buffer the output
> and replace a palceholder in a template with the buffer while we are
> in another template (site-template, list-templates, item-templates)
>
>



-- 
Laruence  Xinchen Hui
http://www.laruence.com/

---

## #56318 — Laruence — 2011-11-13T16:03:16+00:00

URL: https://externals.io/message/56312#56318 · In reply to: #56314

Hi:
<?php
var_dump(get_extension_funcs('zlib'));


result:

$ php54 /tmp/1.php
array(24) {
  [0]=>
  string(10) "readgzfile"
  [1]=>
  string(8) "gzrewind"
  [2]=>
  string(7) "gzclose"
  [3]=>
  string(5) "gzeof"
  [4]=>
  string(6) "gzgetc"
  [5]=>
  string(6) "gzgets"
  [6]=>
  string(7) "gzgetss"
  [7]=>
  string(6) "gzread"
  [8]=>
  string(6) "gzopen"
  [9]=>
  string(10) "gzpassthru"
  [10]=>
  string(6) "gzseek"
  [11]=>
  string(6) "gztell"
  [12]=>
  string(7) "gzwrite"
  [13]=>
  string(6) "gzputs"
  [14]=>
  string(6) "gzfile"
  [15]=>
  string(10) "gzcompress"
  [16]=>
  string(12) "gzuncompress"
  [17]=>
  string(9) "gzdeflate"
  [18]=>
  string(9) "gzinflate"
  [19]=>
  string(8) "gzencode"
  [20]=>
  string(8) "gzdecode"
  [21]=>
  string(11) "zlib_encode"
  [22]=>
  string(11) "zlib_decode"
  [23]=>
  string(20) "zlib_get_coding_type"

  as we can see, the ob_gzhandler is missed in trunk.

thanks


> All the ob_* tests are still in 5.4 and they all pass, so no, these
> functions have not been removed.
>
> 
> > […]
>
>
> --
> 
> 
>
>



-- 
Laruence  Xinchen Hui
http://www.laruence.com/

---

## #56320 — Stas Malyshev — 2011-11-13T20:16:52+00:00

URL: https://externals.io/message/56312#56320 · In reply to: #56312

> Hi:
>
> this revisioin remove the ob_* functions:
> http://svn.php.net/viewvc?view=revision&revision=299980

Indeed, I do not see ob_gzhandler in the function list, but no mention 
of that in UPGRADING or other docs. As far as I understand, it was 
converted from function to alias name, so function does not exist 
anymore. Not sure if it was really needed, as the use case for it is now 
covered by the alias.

Michael, as the patch committer, could you shed more light on this?
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #56323 — Nicolas Grekas — 2011-11-14T09:24:11+00:00

URL: https://externals.io/message/56312#56323 · In reply to: #56320

>
> Indeed, I do not see ob_gzhandler in the function list
>

Personally, I do use ob_gzhandler as a function, so are some some other
projects :

http://www.google.com/codesearch#search/&q=lang:php "ob_gzhandler("

if the function could be reintroduced that would be cool...

Nicolas

---

## #56324 — Michael Wallner — 2011-11-14T10:42:01+00:00

URL: https://externals.io/message/56312#56324 · In reply to: #56320

> 
> > […]
> 
> Indeed, I do not see ob_gzhandler in the function list, but no mention
> of that in UPGRADING or other docs. As far as I understand, it was
> converted from function to alias name, so function does not exist
> anymore. Not sure if it was really needed, as the use case for it is now
> covered by the alias.
> 
> Michael, as the patch committer, could you shed more light on this?

Right, the PHP_FUNCTION ob_gzhandler has been removed and an alias
to the internal "zlib output compression" output handler has been 
introduced, which is faster, can maintain a stateful context and
is cleanable as long as no output has been passed along.

What did people use ob_gzhandler for directly?

Mike

---

## #56326 — Stas Malyshev — 2011-11-14T19:59:04+00:00

URL: https://externals.io/message/56312#56326 · In reply to: #56324

Hi!

> What did people use ob_gzhandler for directly?

Well, apparently they did for some reason, doing custom output handlers 
based on it I guess. So the question is - is it possible to still have 
this function implemented?
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #56387 — Michael Wallner — 2011-11-18T09:18:44+00:00

URL: https://externals.io/message/56312#56387 · In reply to: #56326

> Well, apparently they did for some reason, doing custom output handlers
> based on it I guess. So the question is - is it possible to still have
> this function implemented?

I'll try to hack up a replacement.  It would definitely help if people
could post some exemplar test code to ensure it does what you expect it 
to do...


Thanks,
Mike

---

## #56391 — Nicolas Grekas — 2011-11-18T11:46:05+00:00

URL: https://externals.io/message/56312#56391 · In reply to: #56387

Without a real ob_gzhandler function, replacing it with an alias as
currently in RC1 : what if someone then creates an ob_gzhandler function in
userland ? would ob_start('ob_gzhandler') use the userland function or
still the alias ? I think this is a second argument to make ob_gzhandler a
real function : least surprise.

Personally, I do use ob_gzhandler directly because it's the easiest way to
do chunked compressed encoding in userland.

This allows me to ask for compression as late as possible, because
registering an ob_start('ob_gzhandler'); may be too early for me. I do want
to choose to enable compression only when the very first byte is about to
be sent over the wire.

Hope it helps

Nicolas

<?php

function my_ob_handler($buffer, $mode)
{
// based on content-type,
// do some $buffer filtering
// and add some `header()`

if (/* content-type benefits compression based on some userland rules */)
{
  $buffer = ob_gzhandler($buffer, $mode); // benefits from gzip
negotiation, chunked compression and related headers

  if (PHP_OUTPUT_HANDLER_START & $mode)
  {
  // play/fix with Vary: header, as sent by ob_gzhandler or before
  }
}

return $buffer;
}

---

## #56409 — Michael Wallner — 2011-11-18T19:11:19+00:00

URL: https://externals.io/message/56312#56409 · In reply to: #56391

> Without a real ob_gzhandler function, replacing it with an alias as
> currently in RC1 : what if someone then creates an ob_gzhandler function
> in userland ? would ob_start('ob_gzhandler') use the userland function
> or still the alias ? I think this is a second argument to make
> ob_gzhandler a real function : least surprise.

Why make others suffer, just if you want to?

> 
> Personally, I do use ob_gzhandler directly because it's the easiest way
> to do chunked compressed encoding in userland.
> 
> This allows me to ask for compression as late as possible, because
> registering an ob_start('ob_gzhandler'); may be too early for me. I do
> want to choose to enable compression only when the very first byte is
> about to be sent over the wire.
> 
> Hope it helps
> 
> Nicolas
> 
> <?php
> 
> function my_ob_handler($buffer, $mode)
> {
> // based on content-type,
> // do some $buffer filtering // and add some `header()`
> 
> if (/* content-type benefits compression based on some userland rules
> */) {
>   $buffer = ob_gzhandler($buffer, $mode); // benefits from gzip
> negotiation, chunked compression and related headers
> 
>   if (PHP_OUTPUT_HANDLER_START & $mode)
>   {
>   // play/fix with Vary: header, as sent by ob_gzhandler or before }
> }
> 
> return $buffer;
> }

Looks like a bad hack, but anyway, here's is another hack [1].

It's a patch for ext/zlib, which should make your hack work again... 
whoever might find worth the hassle, may commit it...  or insist
on me to do so...

Regards,
Mike

[1] http://dev.iworks.at/PATCHES/ob_gzhandler.diff.txt

---

## #56815 — Nicolas Grekas — 2011-12-06T17:00:52+00:00

URL: https://externals.io/message/56312#56815 · In reply to: #56391

Hi,

I don't want anyone to take it personal... But what is the status about
missing ob_gzhandler function (but also ob_tidyhandler and
ob_iconv_handler) ?

I put mike's patch and a comment to help track the BC break /potential
inconsistency :

https://bugs.php.net/bug.php?id=60326

Regards
Nicolas

On Fri, Nov 18, 2011 at 12:46, Nicolas Grekas
<nicolas.grekas+php@gmail.com>wrote:

> Without a real ob_gzhandler function, replacing it with an alias as
> currently in RC1 : what if someone then creates an ob_gzhandler function in
> userland ? would ob_start('ob_gzhandler') use the userland function or
> still the alias ? I think this is a second argument to make ob_gzhandler a
> real function : least surprise.
>
> Personally, I do use ob_gzhandler directly because it's the easiest way to
> do chunked compressed encoding in userland.
>
> This allows me to ask for compression as late as possible, because
> registering an ob_start('ob_gzhandler'); may be too early for me. I do want
> to choose to enable compression only when the very first byte is about to
> be sent over the wire.
>
> Hope it helps
>
> Nicolas
>
> <?php
>
> function my_ob_handler($buffer, $mode)
> {
> // based on content-type,
> // do some $buffer filtering
> // and add some `header()`
>
> if (/* content-type benefits compression based on some userland rules */)
> {
>   $buffer = ob_gzhandler($buffer, $mode); // benefits from gzip
> negotiation, chunked compression and related headers
>
>   if (PHP_OUTPUT_HANDLER_START & $mode)
>   {
>   // play/fix with Vary: header, as sent by ob_gzhandler or before
>   }
> }
>
> return $buffer;
> }

---

## #56816 — Stas Malyshev — 2011-12-06T19:07:00+00:00

URL: https://externals.io/message/56312#56816 · In reply to: #56815

Hi!

> I don't want anyone to take it personal... But what is the status about
> missing ob_gzhandler function (but also ob_tidyhandler and
> ob_iconv_handler) ?
>
> I put mike's patch and a comment to help track the BC break /potential
> inconsistency :
>
> https://bugs.php.net/bug.php?id=60326

Ah, I didn't realize this is patch from Mike. Let me take another look 
into it but I think it can be applied unless anyone sees anything wrong 
with it.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #56841 — Michael Wallner — 2011-12-07T20:31:25+00:00

URL: https://externals.io/message/56312#56841 · In reply to: #56816

> > […]
> 
> Ah, I didn't realize this is patch from Mike. Let me take another look
> into it but I think it can be applied unless anyone sees anything wrong
> with it.

Note that despite I wrote the patch, I'm -1 on it, as stated in the 
previous message in this thread.

Regards,
Mike

---

## #56842 — Stas Malyshev — 2011-12-07T20:38:40+00:00

URL: https://externals.io/message/56312#56842 · In reply to: #56841

Hi!

> Note that despite I wrote the patch, I'm -1 on it, as stated in the
> previous message in this thread.

So what you prefer to do instead? I'd like to have `ob_gzhandler()`, but 
if you think it can be done better way, please advise.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #57156 — Nicolas Grekas — 2011-12-30T09:29:09+00:00

URL: https://externals.io/message/56312#57156 · In reply to: #56842

Sorry to insist, but taking the same argument in the thread for
REQUEST_TIME :

  - x.y.z to x.y+1.z
>      - (...)
>      - Backward compatibility must be kept
>
> ( https://wiki.php.net/rfc/releaseprocess )
>


What is the status of this ?




> Note that despite I wrote the patch, I'm -1 on it, as stated in the
> > […]
>
> So what you prefer to do instead? I'd like to have `ob_gzhandler()`, but if
> you think it can be done better way, please advise.

---

## #57157 — Michael Wallner — 2011-12-30T09:57:24+00:00

URL: https://externals.io/message/56312#57157 · In reply to: #57156

> What is the status of this ?

Looks like it's already been committed.

Regards,
Mike
