Skip to content

Commit c1bb3a7

Browse files
author
diabl0
committed
Fixed issue when multiple calls to validate method triggers "must not specify both host and endpoint" exception
1 parent ffccb11 commit c1bb3a7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/ArangoDBClient/ConnectionOptions.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,17 @@ private function validate()
368368
throw new ClientException('port should be an integer');
369369
}
370370

371-
if (isset($this->_values[self::OPTION_HOST]) && !isset($this->_values[self::OPTION_ENDPOINT])) {
372-
// upgrade host/port to an endpoint
373-
$this->_values[self::OPTION_ENDPOINT] = 'tcp://' . $this->_values[self::OPTION_HOST] . ':' . $this->_values[self::OPTION_PORT];
371+
// can use either endpoint or host/port
372+
if (isset($this->_values[self::OPTION_HOST], $this->_values[self::OPTION_ENDPOINT])) {
373+
throw new ClientException('must not specify both host and endpoint');
374+
} else {
375+
if (isset($this->_values[self::OPTION_HOST]) && !isset($this->_values[self::OPTION_ENDPOINT])) {
376+
// upgrade host/port to an endpoint
377+
$this->_values[self::OPTION_ENDPOINT] = 'tcp://' . $this->_values[self::OPTION_HOST] . ':' . $this->_values[self::OPTION_PORT];
378+
unset($this->_values[self::OPTION_HOST]);
379+
}
374380
}
375381

376-
377382
// set up a new endpoint, this will also validate it
378383
$this->getEndpoint();
379384

0 commit comments

Comments
 (0)