Skip to content

Commit

Permalink
Fixing CakeSocket::write() to better work with fwrite() oddities
Browse files Browse the repository at this point in the history
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
  • Loading branch information
markstory committed Apr 8, 2011
1 parent 548a64e commit 7d15c9d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cake/libs/cake_socket.php
Expand Up @@ -212,8 +212,14 @@ function write($data) {
return false;
}
}

return fwrite($this->connection, $data, strlen($data));
$totalBytes = strlen($data);
for ($written = 0, $rv = 0; $written < $totalBytes; $written += $rv) {
$rv = fwrite($this->connection, substr($data, $written));
if ($rv === false || $rv === 0) {
return $written;
}
}
return $written;
}

/**
Expand Down

0 comments on commit 7d15c9d

Please sign in to comment.