Bug #81345 [NEW]: ftell() after writing to compress://zlib stream wrong

From: Date: Tue, 10 Aug 2021 13:11:03 +0000
Subject: Bug #81345 [NEW]: ftell() after writing to compress://zlib stream wrong
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235730@lists.php.net to get a copy of this message
From:             cmb
Operating system: *
PHP version:      7.4Git-2021-08-10 (Git)
Package:          Streams related
Bug Type:         Bug
Bug description:ftell() after writing to compress://zlib stream wrong

Description:
------------
After writing to a compress://zlib stream, ftell() reports the
number of uncompressed bytes which have been written, not the
actual stream position.  This is inherently tied to the way the
streams layer works: the stream's write method is supposed to
return the number of input bytes processed, so the same confusing
behavior happens for all streams for which the number of input
bytes is not the same as the number of output bytes.

Since this cannot easily be fixed, it should at least be
documented.


Test script:
---------------
<?php
$s = fopen("compress.zlib://file.gz", "w");
var_dump(fwrite($s, str_repeat("hello world", 100)));
fflush($s); // this doesn't make a difference
var_dump(ftell($s));
fclose($s);
var_dump(filesize("file.gz"));
?>


Expected result:
----------------
int(1100)
int(38)
int(48)


Actual result:
--------------
int(1100)
int(1100)
int(48)


-- 
Edit bug report at https://bugs.php.net/bug.php?id=81345&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81345&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81345&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81345&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81345&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81345&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81345&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81345&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81345&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81345&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81345&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81345&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81345&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81345&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81345&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81345&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81345&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81345&r=mysqlcfg


Thread (1 message)

  • cmb@php.net
« previous php.bugs (#235730) next »