Skip to content

Commit

Permalink
Work-around HHVM < 3.19 appending ":" for all Unix socket addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed May 8, 2017
1 parent 74a194f commit b457f4d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,15 @@ private function parseAddress($address)
}

if ($this->unix) {
// unknown addresses should not return a NULL-byte string
if ($address === "\x00") {
// remove trailing colon from address for HHVM < 3.19: https://3v4l.org/5C1lo
// note that techncially ":" is a valid address, so keep this in place otherwise
if (substr($address, -1) === ':' && defined('HHVM_VERSION') && HHVM_VERSION < 3.19) {
$address = (string)substr($address, 0, -1);
}

// work around unknown addresses should return null value: https://3v4l.org/5C1lo
// PHP uses "\0" string and HHVM uses empty string (colon removed above)
if ($address === "\x00" || $address === '') {
return null;
}

Expand Down

0 comments on commit b457f4d

Please sign in to comment.