Skip to content

Commit a2b92d6

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #81346: Non-seekable streams don't update position after write
2 parents 2e71c94 + 4a1af1f commit a2b92d6

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ PHP NEWS
44

55
- Core:
66
. Fixed bug #81302 (Stream position after stream filter removed). (cmb)
7+
. Fixed bug #81346 (Non-seekable streams don't update position after write).
8+
(cmb)
79

810
26 Aug 2021, PHP 8.0.10
911

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #81346 (Non-seekable streams don't update position after write)
3+
--DESCRIPTION--
4+
The test expectation is due to bug #81345.
5+
--SKIPIF--
6+
<?php
7+
if (!extension_loaded('bz2')) die("bz2 extension not available");
8+
?>
9+
--FILE--
10+
<?php
11+
$s = fopen("compress.bzip2://" . __DIR__ . "/bug81346.bz2", "w");
12+
fwrite($s, str_repeat("hello world", 100));
13+
fflush($s);
14+
var_dump(ftell($s));
15+
?>
16+
--CLEAN--
17+
<?php
18+
@unlink(__DIR__ . "/bug81346.bz2");
19+
?>
20+
--EXPECT--
21+
int(1100)

main/streams/streams.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,12 +1144,7 @@ static ssize_t _php_stream_write_buffer(php_stream *stream, const char *buf, siz
11441144
buf += justwrote;
11451145
count -= justwrote;
11461146
didwrite += justwrote;
1147-
1148-
/* Only screw with the buffer if we can seek, otherwise we lose data
1149-
* buffered from fifos and sockets */
1150-
if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
1151-
stream->position += justwrote;
1152-
}
1147+
stream->position += justwrote;
11531148
}
11541149

11551150
return didwrite;

0 commit comments

Comments
 (0)