From dd2e6e866db17e4458a706b729288bfae857fa17 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 30 Jun 2015 07:02:32 +0200 Subject: [PATCH] Fix test failures from previous commit (I really don't get that issue in phar... if there's a better fix, it's welcome...) --- Zend/tests/bug38779_1.phpt | 3 +-- ext/phar/stream.c | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Zend/tests/bug38779_1.phpt b/Zend/tests/bug38779_1.phpt index e2a5b208c6..1cd25f90f3 100644 --- a/Zend/tests/bug38779_1.phpt +++ b/Zend/tests/bug38779_1.phpt @@ -20,10 +20,10 @@ class Loader { return $this->position >= strlen($this->data); } function stream_flush() { - @unlink(dirname(__FILE__)."/bug38779.txt"); var_dump("flush!"); } function stream_close() { + @unlink(dirname(__FILE__)."/bug38779.txt"); var_dump("close!"); } } @@ -49,5 +49,4 @@ if (file_exists($filename)) { ?> --EXPECTF-- Parse error: %s error%sin %s on line %d -string(6) "flush!" string(6) "close!" diff --git a/ext/phar/stream.c b/ext/phar/stream.c index fc477f0b9b..9aa3c03a5d 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -346,6 +346,9 @@ phar_stub: */ static int phar_stream_close(php_stream *stream, int close_handle) /* {{{ */ { + /* for some reasons phar needs to be flushed even if there is no write going on */ + phar_stream_flush(stream); + phar_entry_delref((phar_entry_data *)stream->abstract); return 0; @@ -437,7 +440,7 @@ static size_t phar_stream_write(php_stream *stream, const char *buf, size_t coun php_stream_seek(data->fp, data->position, SEEK_SET); if (count != php_stream_write(data->fp, buf, count)) { php_stream_wrapper_log_error(stream->wrapper, stream->flags, "phar error: Could not write %d characters to \"%s\" in phar \"%s\"", (int) count, data->internal_file->filename, data->phar->fname); - return -1; + return 0; } data->position = php_stream_tell(data->fp); if (data->position > (zend_off_t)data->internal_file->uncompressed_filesize) { -- 2.40.0