Skip to content

Commit 5a62840

Browse files
committed
Don't raise bogus warning if writing completely failed
1 parent ba54a46 commit 5a62840

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/standard/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ PHP_FUNCTION(file_put_contents)
655655
case IS_STRING:
656656
if (Z_STRLEN_P(data)) {
657657
numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data));
658-
if (numbytes != Z_STRLEN_P(data)) {
658+
if (numbytes != -1 && numbytes != Z_STRLEN_P(data)) {
659659
php_error_docref(NULL, E_WARNING, "Only %zd of %zd bytes written, possibly out of free disk space", numbytes, Z_STRLEN_P(data));
660660
numbytes = -1;
661661
}
@@ -691,7 +691,7 @@ PHP_FUNCTION(file_put_contents)
691691

692692
if (zend_std_cast_object_tostring(Z_OBJ_P(data), &out, IS_STRING) == SUCCESS) {
693693
numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRLEN(out));
694-
if (numbytes != Z_STRLEN(out)) {
694+
if (numbytes != -1 && numbytes != Z_STRLEN(out)) {
695695
php_error_docref(NULL, E_WARNING, "Only %zd of %zd bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out));
696696
numbytes = -1;
697697
}

0 commit comments

Comments
 (0)