Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/php/lib/Transport/TSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function open()
throw new TTransportException('Cannot open null host', TTransportException::NOT_OPEN);
}

if ($this->port_ <= 0) {
if ($this->port_ <= 0 && strpos($this->host_, 'unix://') !== 0) {
throw new TTransportException('Cannot open without port', TTransportException::NOT_OPEN);
}

Expand Down
27 changes: 27 additions & 0 deletions lib/php/test/Unit/Lib/Transport/TSocketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,33 @@ public function testOpenPersist()
$this->assertTrue($transport->isOpen());
}

public function testOpenUnixSocket()
{
$host = 'unix:///tmp/ipc.sock';
$port = -1;
$persist = false;
$debugHandler = null;

$this->getFunctionMock('Thrift\Transport', 'fsockopen')
->expects($this->once())
->with(
$host,
$port,
$this->anything(), #$errno,
$this->anything(), #$errstr,
$this->anything() #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000),
);

$transport = new TSocket(
$host,
$port,
$persist,
$debugHandler
);

$transport->open();
}

/**
* @dataProvider open_THRIFT_5132_DataProvider
*/
Expand Down
Loading