]> granicus.if.org Git - php/commitdiff
Fix test failures from previous commit
authorBob Weinand <bobwei9@hotmail.com>
Tue, 30 Jun 2015 05:02:32 +0000 (07:02 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Tue, 30 Jun 2015 05:02:56 +0000 (07:02 +0200)
(I really don't get that issue in phar... if there's a better fix, it's welcome...)

Zend/tests/bug38779_1.phpt
ext/phar/stream.c

index e2a5b208c6c99c24417335a6b42eccc4d0cb8420..1cd25f90f35380851be42c2af8afe379a603e862 100644 (file)
@@ -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!"
index fc477f0b9bb8b10a172cc2ab2084e75b89ae3e97..9aa3c03a5d1ca6519f09a95c978a48ca05fae502 100644 (file)
@@ -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) {