Skip to content
Open
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
4 changes: 3 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Http/Https adapter options:
* headers - array of custom headers
* curl - array of CURL settings as option=>value
* persistent - define whether the connection is persistent or not
* bigint_to_string - define whether big integers in response are converted to strings or not

A simple example of multiple hosts:
```
Expand Down Expand Up @@ -92,7 +93,8 @@ A more advanced example where one host uses HTTP authentication and another requ
'curl' => [
CURLOPT_FAILONERROR => true
],
'persistent' => true
'persistent' => true,
'bigint_to_string' => true,
],
[
'host' => '123.0.0.2',
Expand Down
3 changes: 3 additions & 0 deletions src/Manticoresearch/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ public function explainQuery(array $params = []) {
public function request(Request $request, array $params = [], string $retryReason = ''): Response {
try {
$connection = $this->connectionPool->getConnection($retryReason);
if (isset($this->config['bigint_to_string']) && $this->config['bigint_to_string']) {
$params['bigIntToString'] = true;
}
$this->lastResponse = $connection->getTransportHandler($this->logger)
->execute($request, $params);
if ($this->connectionPool->retriesAttempts) {
Expand Down
17 changes: 16 additions & 1 deletion src/Manticoresearch/Response.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class Response
*/
protected $params;

/**
* flag defining to apply or not bigint to string conversion
* @var bool
*/
protected $bigIntToString = false;

public function __construct($responseString, $status = null, $params = []) {
if (is_array($responseString)) {
Expand All @@ -71,7 +76,9 @@ public function __construct($responseString, $status = null, $params = []) {
*/
public function getResponse() {
if (null === $this->response) {
$this->response = json_decode($this->string, true);
$this->response = $this->bigIntToString
? json_decode($this->string, true, 512, JSON_BIGINT_AS_STRING)
: json_decode($this->string, true);
if (json_last_error() !== JSON_ERROR_NONE) {
if (json_last_error() !== JSON_ERROR_UTF8 || !$this->stripBadUtf8()) {
throw new RuntimeException(
Expand Down Expand Up @@ -178,4 +185,12 @@ public function setTransportInfo($info) {
public function getTransportInfo() {
return $this->transportInfo;
}

/**
* @return void
*/
public function enableBigintConversion() {
$this->bigIntToString = true;
}

}
4 changes: 4 additions & 0 deletions src/Manticoresearch/Transport/Http.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public function execute(Request $request, $params = []) {
$response = new Response($responseString, $status);
}

if (isset($params['bigIntToString'])) {
$response->enableBigintConversion();
}

$time = $end - $start;
$response->setTime($time);
$response->setTransportInfo(
Expand Down
4 changes: 4 additions & 0 deletions src/Manticoresearch/Transport/PhpHttp.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public function execute(Request $request, $params = []) {
$response = new Response($responseString, $status);
}

if (isset($params['bigIntToString'])) {
$response->enableBigintConversion();
}

$time = $end - $start;
$response->setTime($time);
$response->setTransportInfo(
Expand Down
2 changes: 2 additions & 0 deletions test/Manticoresearch/Endpoints/Nodes/VariablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function testVariables() {
'collation_connection',
'distinct_precision_threshold',
'grouping_in_utc',
'interactive_timeout',
'last_insert_id',
'log_level',
'max_allowed_packet',
Expand All @@ -42,6 +43,7 @@ public function testVariables() {
'threads_ex_effective',
'timezone',
'user',
'wait_timeout',
], $keys
);
}
Expand Down
Loading