com php-src: Fixed bug #71287 (Error message contains hexadecimal instead of decimal number): NEWS ext/standard/file.c
ext/standard/tests/file/bug71287.phpt
| From: | Xinchen Hui | Date: | Tue, 05 Jan 2016 16:01:44 +0000 |
| Subject: | com php-src: Fixed bug #71287 (Error message contains hexadecimal instead of decimal number): NEWS ext/standard/file.c ext/standard/tests/file/bug71287.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90520@lists.php.net to get a copy of this message | ||
Commit: 695e8b79aff3108327d0189dba0abf05f58be847
Author: Xinchen Hui <laruence@gmail.com> Wed, 6 Jan 2016 00:01:44 +0800
Parents: d4da32d3125f3a2220023bd123cfbabdc2939b71
Branches: PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=695e8b79aff3108327d0189dba0abf05f58be847
Log:
Fixed bug #71287 (Error message contains hexadecimal instead of decimal number)
Bugs:
https://bugs.php.net/71287
Changed paths:
M NEWS
M ext/standard/file.c
A ext/standard/tests/file/bug71287.phpt
Diff:
diff --git a/NEWS b/NEWS
index cc43981..bfaf241 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,8 @@ PHP NEWS
immediately). (Laruence)
- Standard:
+ . Fixed bug #71287 (Error message contains hexadecimal instead of decimal
+ number). (Laruence)
. Fixed bug #71264 (file_put_contents() returns unexpected value when
filesystem runs full). (Laruence)
. Fixed bug #71245 (file_get_contents() ignores "header" context option if
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 4f3a6ab..26f5c16 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -642,7 +642,7 @@ PHP_FUNCTION(file_put_contents)
if (Z_STRLEN_P(data)) {
numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data));
if (numbytes != Z_STRLEN_P(data)) {
- php_error_docref(NULL, E_WARNING, "Only %pl of %zd bytes written, possibly out of free
disk space", numbytes, Z_STRLEN_P(data));
+ php_error_docref(NULL, E_WARNING, "Only "ZEND_LONG_FMT" of %zd bytes written,
possibly out of free disk space", numbytes, Z_STRLEN_P(data));
numbytes = -1;
}
}
@@ -677,7 +677,7 @@ PHP_FUNCTION(file_put_contents)
if (zend_std_cast_object_tostring(data, &out, IS_STRING) == SUCCESS) {
numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRLEN(out));
if (numbytes != Z_STRLEN(out)) {
- php_error_docref(NULL, E_WARNING, "Only %pd of %zd bytes written, possibly out of free
disk space", numbytes, Z_STRLEN(out));
+ php_error_docref(NULL, E_WARNING, "Only "ZEND_LONG_FMT" of %zd bytes written,
possibly out of free disk space", numbytes, Z_STRLEN(out));
numbytes = -1;
}
zval_dtor(&out);
diff --git a/ext/standard/tests/file/bug71287.phpt b/ext/standard/tests/file/bug71287.phpt
new file mode 100644
index 0000000..b798782
--- /dev/null
+++ b/ext/standard/tests/file/bug71287.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #71287 (Error message contains hexadecimal instead of decimal number)
+--FILE--
+<?php
+class Stream {
+ public function stream_open($path, $mode, $options, $opened_path) {
+ return true;
+ }
+
+ public function stream_write($data) {
+ return strlen($data) - 2;
+ }
+}
+
+stream_wrapper_register('test', Stream::class);
+file_put_contents('test://file.txt', 'foobarbaz');
+?>
+--EXPECTF--
+Warning: file_put_contents(): Only 7 of 9 bytes written, possibly out of free disk space in
%sbug71287.php on line %d