Skip to content

Commit e9b2852

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #81346: Non-seekable streams don't update position after write
2 parents 961ac1f + a2b92d6 commit e9b2852

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
--EXTENSIONS--
6+
bz2
7+
--FILE--
8+
<?php
9+
$s = fopen("compress.bzip2://" . __DIR__ . "/bug81346.bz2", "w");
10+
fwrite($s, str_repeat("hello world", 100));
11+
fflush($s);
12+
var_dump(ftell($s));
13+
?>
14+
--CLEAN--
15+
<?php
16+
@unlink(__DIR__ . "/bug81346.bz2");
17+
?>
18+
--EXPECT--
19+
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)