From: Christoph M. Becker Date: Sat, 2 May 2020 14:28:18 +0000 (+0200) Subject: Don't raise bogus warning if writing completely failed X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a628402a0a9740b5e988e79b008696ccfb73329;p=php Don't raise bogus warning if writing completely failed --- diff --git a/ext/standard/file.c b/ext/standard/file.c index d14d8fed25..9d8c6a77d9 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -655,7 +655,7 @@ PHP_FUNCTION(file_put_contents) case IS_STRING: if (Z_STRLEN_P(data)) { numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data)); - if (numbytes != Z_STRLEN_P(data)) { + if (numbytes != -1 && numbytes != Z_STRLEN_P(data)) { php_error_docref(NULL, E_WARNING, "Only %zd of %zd bytes written, possibly out of free disk space", numbytes, Z_STRLEN_P(data)); numbytes = -1; } @@ -691,7 +691,7 @@ PHP_FUNCTION(file_put_contents) if (zend_std_cast_object_tostring(Z_OBJ_P(data), &out, IS_STRING) == SUCCESS) { numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRLEN(out)); - if (numbytes != Z_STRLEN(out)) { + if (numbytes != -1 && numbytes != Z_STRLEN(out)) { php_error_docref(NULL, E_WARNING, "Only %zd of %zd bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out)); numbytes = -1; }