Skip to content

Commit

Permalink
Only do file_get_contents on PHP versions needed
Browse files Browse the repository at this point in the history
  • Loading branch information
cboden committed Aug 31, 2014
1 parent 44ab73c commit aa071b8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/StreamEncryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,23 @@ class StreamEncryption

private $errstr;
private $errno;

private $wrapSecure = false;

public function __construct(LoopInterface $loop)
{
$this->loop = $loop;

// See https://bugs.php.net/bug.php?id=65137
// On versions affected by this bug we need to fread the stream until we
// get an empty string back because the buffer indicator could be wrong
if (
PHP_VERSION_ID < 50433
|| (PHP_VERSION_ID >= 50000 && PHP_VERSION_ID < 50517)
|| PHP_VERSION_ID === 50600
) {

This comment has been minimized.

Copy link
@cboden

cboden Aug 31, 2014

Author Contributor

@DaveRandom Can you confirm this is targeting all the correct versions please?

This comment has been minimized.

Copy link
@DaveRandom

DaveRandom Sep 1, 2014

Contributor

Presumably >= 50000 is supposed to say >= 50500? Apart from that it looks good, although it's not over until the fat lady sings (i.e. the versions are tagged and released)

This comment has been minimized.

Copy link
@cboden

cboden Sep 2, 2014

Author Contributor

whoops!

$this->wrapSecure = true;
}
}

public function enable(Stream $stream)
Expand Down Expand Up @@ -59,7 +72,7 @@ public function toggle(Stream $stream, $toggle)
$toggleCrypto();

return $deferred->promise()->then(function () use ($stream, $toggle) {
if ($toggle) {
if ($toggle && $this->wrapSecure) {
return new SecureStream($stream, $this->loop);
}

Expand Down

0 comments on commit aa071b8

Please sign in to comment.