Skip to content

Commit 08ec409

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: phar: Fix broken return value of fflush() for phar file entries
2 parents fd5c14e + 2f9d86b commit 08ec409

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ PHP NEWS
2525
- Phar:
2626
. Fixed bug GH-20442 (Phar does not respect case-insensitiveness of
2727
__halt_compiler() when reading stub). (ndossche, TimWolla)
28+
. Fix broken return value of fflush() for phar file entries. (ndossche)
2829

2930
- PHPDBG:
3031
. Fixed ZPP type violation in phpdbg_get_executable() and phpdbg_end_oplog().

ext/phar/phar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3185,7 +3185,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
31853185
return EOF;
31863186
}
31873187

3188-
return EOF;
3188+
return 0;
31893189

31903190
cleanup:
31913191
if (shared_cfp != NULL) {

ext/phar/tar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa
11781178

11791179
/* on error in the hash iterator above, error is set */
11801180
php_stream_close(newfile);
1181-
return;
1181+
return EOF;
11821182
}
11831183

11841184
/* add signature for executable tars or tars explicitly set with setSignatureAlgorithm */
@@ -1343,6 +1343,6 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa
13431343
php_stream_close(newfile);
13441344
}
13451345
}
1346-
return EOF;
1346+
return 0;
13471347
}
13481348
/* }}} */
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
fflush() on phar file should report success
3+
--EXTENSIONS--
4+
phar
5+
--INI--
6+
phar.readonly=0
7+
--FILE--
8+
<?php
9+
10+
$phar = new Phar(__DIR__.'/fflush_phar_file_report_success.phar');
11+
$phar->addFromString('test', 'contents');
12+
unset($phar);
13+
14+
$f = fopen('phar://' . __DIR__.'/fflush_phar_file_report_success.phar/test', 'w');
15+
var_dump(fflush($f));
16+
var_dump(fclose($f));
17+
18+
?>
19+
--CLEAN--
20+
<?php
21+
@unlink(__DIR__.'/fflush_phar_file_report_success.phar');
22+
?>
23+
--EXPECT--
24+
bool(true)
25+
bool(true)

ext/phar/zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,6 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa
15271527
if (must_close_old_file) {
15281528
php_stream_close(oldfile);
15291529
}
1530-
return EOF;
1530+
return 0;
15311531
}
15321532
/* }}} */

0 commit comments

Comments
 (0)