diff --git a/NEWS b/NEWS index 6b866f2ec35..e99620d7283 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ PHP NEWS - Phar: . Fixed bug GH-20442 (Phar does not respect case-insensitiveness of __halt_compiler() when reading stub). (ndossche, TimWolla) + . Fix broken return value of fflush() for phar file entries. (ndossche) - PHPDBG: . Fixed ZPP type violation in phpdbg_get_executable() and phpdbg_end_oplog(). diff --git a/ext/phar/phar.c b/ext/phar/phar.c index c01ffc9b6e0..3a2c226e549 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -3185,7 +3185,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau return EOF; } - return EOF; + return 0; cleanup: if (shared_cfp != NULL) { diff --git a/ext/phar/tar.c b/ext/phar/tar.c index d53d3a7107e..ec4e859d5e8 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -1178,7 +1178,7 @@ nostub: /* on error in the hash iterator above, error is set */ php_stream_close(newfile); - return; + return EOF; } /* add signature for executable tars or tars explicitly set with setSignatureAlgorithm */ @@ -1343,6 +1343,6 @@ nostub: php_stream_close(newfile); } } - return EOF; + return 0; } /* }}} */ diff --git a/ext/phar/tests/fflush_phar_file_report_success.phpt b/ext/phar/tests/fflush_phar_file_report_success.phpt new file mode 100644 index 00000000000..615f4e58e56 --- /dev/null +++ b/ext/phar/tests/fflush_phar_file_report_success.phpt @@ -0,0 +1,25 @@ +--TEST-- +fflush() on phar file should report success +--EXTENSIONS-- +phar +--INI-- +phar.readonly=0 +--FILE-- +addFromString('test', 'contents'); +unset($phar); + +$f = fopen('phar://' . __DIR__.'/fflush_phar_file_report_success.phar/test', 'w'); +var_dump(fflush($f)); +var_dump(fclose($f)); + +?> +--CLEAN-- + +--EXPECT-- +bool(true) +bool(true) diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 5bb0e6986bb..9a1a724cb62 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -1527,6 +1527,6 @@ nocentralerror: if (must_close_old_file) { php_stream_close(oldfile); } - return EOF; + return 0; } /* }}} */