Skip to content

Commit 7d15c9d

Browse files
committed
Fixing CakeSocket::write() to better work with fwrite() oddities
where fwrite() won't actually write all the content, instead only part of the content would be written. All content should be written now. Fixes #1616
1 parent 548a64e commit 7d15c9d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cake/libs/cake_socket.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,14 @@ function write($data) {
212212
return false;
213213
}
214214
}
215-
216-
return fwrite($this->connection, $data, strlen($data));
215+
$totalBytes = strlen($data);
216+
for ($written = 0, $rv = 0; $written < $totalBytes; $written += $rv) {
217+
$rv = fwrite($this->connection, substr($data, $written));
218+
if ($rv === false || $rv === 0) {
219+
return $written;
220+
}
221+
}
222+
return $written;
217223
}
218224

219225
/**

0 commit comments

Comments
 (0)