Skip to content

Commit 1cbcf0f

Browse files
committed
Throw notice for plain wrapper fread/fwrite errors
Similar to what is done for socket read/write errors.
1 parent dee243d commit 1cbcf0f

37 files changed

+954
-629
lines changed

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ PHP 7.4 UPGRADE NOTES
142142
. fread() and fwrite() will now return false if the operation failed.
143143
Previously an empty string or 0 was returned. EAGAIN/EWOULDBLOCK are not
144144
considered failures.
145+
. fread() and fwrite() on plain files will now throw a notice on failure,
146+
such as when trying to write to a read-only file resource.
145147

146148
- Tokenizer:
147149
. token_get_all() will now emit a T_BAD_CHARACTER token for unexpected

ext/fileinfo/tests/bug61964-mb.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ rmdir($dir);
4545
?>
4646
===DONE===
4747
--EXPECTF--
48-
bool(false)
48+
bool(false)%A
4949
resource(%d) of type (file_info)
5050
resource(%d) of type (file_info)
51-
bool(false)
52-
51+
bool(false)%A
5352
Notice: finfo_open(): Warning: offset `string' invalid in %sbug61964-mb.php on line %d
5453

5554
Notice: finfo_open(): Warning: offset ` Core' invalid in %sbug61964-mb.php on line %d

ext/fileinfo/tests/bug61964.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ rmdir($dir);
4545
?>
4646
===DONE===
4747
--EXPECTF--
48-
bool(false)
48+
bool(false)%A
4949
resource(%d) of type (file_info)
5050
resource(%d) of type (file_info)
51-
bool(false)
52-
51+
bool(false)%A
5352
Notice: finfo_open(): Warning: offset `string' invalid in %sbug61964.php on line %d
5453

5554
Notice: finfo_open(): Warning: offset ` Core' invalid in %sbug61964.php on line %d

ext/standard/tests/file/007_variation1.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ int(0)
4848
string(20) "line
4949
line of text
5050
li"
51+
52+
Notice: fwrite(): write of 37 bytes failed with errno=9 Bad file descriptor in %s on line %d
5153
bool(false)
5254
bool(true)
5355
string(7) "Unknown"

ext/standard/tests/file/007_variation11-win32-mb.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ string(6) "stream"
6868
int(0)
6969
int(37)
7070
int(37)
71+
72+
Notice: fread(): read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
7173
bool(false)
7274
int(0)
7375
bool(true)

ext/standard/tests/file/007_variation11-win32.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ string(6) "stream"
6666
int(0)
6767
int(37)
6868
int(37)
69+
70+
Notice: fread(): read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
6971
bool(false)
7072
int(0)
7173
bool(true)

ext/standard/tests/file/007_variation11.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ string(6) "stream"
6666
int(0)
6767
int(37)
6868
int(37)
69+
70+
Notice: fread(): read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
6971
bool(false)
7072
int(0)
7173
bool(true)

ext/standard/tests/file/007_variation13-win32.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ unlink(__DIR__."/007_variation13.tmp");
5656
resource(%d) of type (stream)
5757
string(6) "stream"
5858
int(37)
59+
60+
Notice: fread(): read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
5961
bool(false)
6062
int(0)
6163
bool(true)

ext/standard/tests/file/007_variation13.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ unlink(__DIR__."/007_variation13.tmp");
5656
resource(%d) of type (stream)
5757
string(6) "stream"
5858
int(37)
59+
60+
Notice: fread(): read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
5961
bool(false)
6062
int(0)
6163
bool(true)

ext/standard/tests/file/007_variation15.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ string(6) "stream"
4949
int(0)
5050
int(37)
5151
int(37)
52+
53+
Notice: fread(): read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
5254
bool(false)
5355
int(0)
5456
bool(true)

0 commit comments

Comments
 (0)