From 6e538a1066be769f1a78185d1579037ab47f33aa Mon Sep 17 00:00:00 2001 From: Mechislav Lipskiy Date: Wed, 19 Jul 2017 00:38:08 +0300 Subject: [PATCH 01/20] + Added: search param into Issues api --- lib/Gitlab/Api/Issues.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Gitlab/Api/Issues.php b/lib/Gitlab/Api/Issues.php index 661ea7ac1..921035a7c 100644 --- a/lib/Gitlab/Api/Issues.php +++ b/lib/Gitlab/Api/Issues.php @@ -13,7 +13,7 @@ public function all($project_id = null, $page = 1, $per_page = self::PER_PAGE, a { $path = $project_id === null ? 'issues' : $this->getProjectPath($project_id, 'issues'); - $params = array_intersect_key($params, array('labels' => '', 'state' => '', 'sort' => '', 'order_by' => '', 'milestone' => '')); + $params = array_intersect_key($params, array('labels' => '', 'state' => '', 'sort' => '', 'order_by' => '', 'milestone' => '', 'search' => '')); $params = array_merge(array( 'page' => $page, 'per_page' => $per_page From 3486c97b3d21d6dc8db7f95097dd9ac1a09c43de Mon Sep 17 00:00:00 2001 From: Mechislav Lipskiy Date: Wed, 19 Jul 2017 00:44:46 +0300 Subject: [PATCH 02/20] + Added: search param into Issues api --- lib/Gitlab/Api/Issues.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Gitlab/Api/Issues.php b/lib/Gitlab/Api/Issues.php index 921035a7c..b05b991cd 100644 --- a/lib/Gitlab/Api/Issues.php +++ b/lib/Gitlab/Api/Issues.php @@ -13,7 +13,7 @@ public function all($project_id = null, $page = 1, $per_page = self::PER_PAGE, a { $path = $project_id === null ? 'issues' : $this->getProjectPath($project_id, 'issues'); - $params = array_intersect_key($params, array('labels' => '', 'state' => '', 'sort' => '', 'order_by' => '', 'milestone' => '', 'search' => '')); + $params = array_intersect_key($params, array('labels' => '', 'state' => '', 'sort' => '', 'order_by' => '', 'search' => '', 'milestone' => '')); $params = array_merge(array( 'page' => $page, 'per_page' => $per_page From 1094e9f0860dc14c151925fce352b157281e0c97 Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 26 Jul 2017 01:44:53 +0300 Subject: [PATCH 03/20] Update Issues.php --- lib/Gitlab/Api/Issues.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Gitlab/Api/Issues.php b/lib/Gitlab/Api/Issues.php index b05b991cd..0387fd190 100644 --- a/lib/Gitlab/Api/Issues.php +++ b/lib/Gitlab/Api/Issues.php @@ -13,7 +13,6 @@ public function all($project_id = null, $page = 1, $per_page = self::PER_PAGE, a { $path = $project_id === null ? 'issues' : $this->getProjectPath($project_id, 'issues'); - $params = array_intersect_key($params, array('labels' => '', 'state' => '', 'sort' => '', 'order_by' => '', 'search' => '', 'milestone' => '')); $params = array_merge(array( 'page' => $page, 'per_page' => $per_page From c2ca23c7da8a95851daad1bb647c4a780378378a Mon Sep 17 00:00:00 2001 From: d3n4 Date: Thu, 3 Aug 2017 01:40:57 +0300 Subject: [PATCH 04/20] Update AbstractApi.php --- lib/Gitlab/Api/AbstractApi.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Gitlab/Api/AbstractApi.php b/lib/Gitlab/Api/AbstractApi.php index d6e3ab723..f181bf762 100644 --- a/lib/Gitlab/Api/AbstractApi.php +++ b/lib/Gitlab/Api/AbstractApi.php @@ -46,7 +46,7 @@ public function configure() * @param array $requestHeaders * @return mixed */ - protected function get($path, array $parameters = array(), $requestHeaders = array()) + public function get($path, array $parameters = array(), $requestHeaders = array()) { $response = $this->client->getHttpClient()->get($path, $parameters, $requestHeaders); @@ -60,7 +60,7 @@ protected function get($path, array $parameters = array(), $requestHeaders = arr * @param array $files * @return mixed */ - protected function post($path, array $parameters = array(), $requestHeaders = array(), array $files = array()) + public function post($path, array $parameters = array(), $requestHeaders = array(), array $files = array()) { $response = $this->client->getHttpClient()->post($path, $parameters, $requestHeaders, $files); @@ -73,7 +73,7 @@ protected function post($path, array $parameters = array(), $requestHeaders = ar * @param array $requestHeaders * @return mixed */ - protected function patch($path, array $parameters = array(), $requestHeaders = array()) + public function patch($path, array $parameters = array(), $requestHeaders = array()) { $response = $this->client->getHttpClient()->patch($path, $parameters, $requestHeaders); @@ -86,7 +86,7 @@ protected function patch($path, array $parameters = array(), $requestHeaders = a * @param array $requestHeaders * @return mixed */ - protected function put($path, array $parameters = array(), $requestHeaders = array()) + public function put($path, array $parameters = array(), $requestHeaders = array()) { $response = $this->client->getHttpClient()->put($path, $parameters, $requestHeaders); @@ -99,7 +99,7 @@ protected function put($path, array $parameters = array(), $requestHeaders = arr * @param array $requestHeaders * @return mixed */ - protected function delete($path, array $parameters = array(), $requestHeaders = array()) + public function delete($path, array $parameters = array(), $requestHeaders = array()) { $response = $this->client->getHttpClient()->delete($path, $parameters, $requestHeaders); From bda7cadf317c6808dad6dbe8c3096b4de7911fcb Mon Sep 17 00:00:00 2001 From: d3n4 Date: Fri, 15 Dec 2017 14:11:29 +0200 Subject: [PATCH 05/20] Update Client.php --- lib/Gitlab/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Gitlab/Client.php b/lib/Gitlab/Client.php index 5f0fd3950..c4c38ba52 100644 --- a/lib/Gitlab/Client.php +++ b/lib/Gitlab/Client.php @@ -58,7 +58,7 @@ class Client */ private $options = array( 'user_agent' => 'php-gitlab-api (http://github.com/m4tthumphrey/php-gitlab-api)', - 'timeout' => 60 + 'timeout' => 960 ); private $baseUrl; From 7fcb8461ee0bf6d9db56149db846380c32692119 Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 1 Aug 2018 17:52:28 +0300 Subject: [PATCH 06/20] Update Client.php --- lib/Gitlab/Client.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Gitlab/Client.php b/lib/Gitlab/Client.php index c4c38ba52..e2fb8f0f2 100644 --- a/lib/Gitlab/Client.php +++ b/lib/Gitlab/Client.php @@ -84,7 +84,8 @@ public function __construct($baseUrl, ClientInterface $httpClient = null, array } $httpClient = $httpClient ?: new Curl(); - $httpClient->setTimeout($this->options['timeout']); + // todo: rewrite hotfix + /*$httpClient->setTimeout($this->options['timeout']);*/ $httpClient->setVerifyPeer(false); $this->baseUrl = $baseUrl; From d4dd2eef2a506842aa8a401f433a406ee464fc64 Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 1 Aug 2018 18:11:45 +0300 Subject: [PATCH 07/20] Update Client.php --- lib/Gitlab/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Gitlab/Client.php b/lib/Gitlab/Client.php index e2fb8f0f2..0bd3f1eda 100644 --- a/lib/Gitlab/Client.php +++ b/lib/Gitlab/Client.php @@ -86,7 +86,7 @@ public function __construct($baseUrl, ClientInterface $httpClient = null, array $httpClient = $httpClient ?: new Curl(); // todo: rewrite hotfix /*$httpClient->setTimeout($this->options['timeout']);*/ - $httpClient->setVerifyPeer(false); + /*$httpClient->setVerifyPeer(false);*/ $this->baseUrl = $baseUrl; $this->httpClient = new HttpClient($this->baseUrl, $this->options, $httpClient); From 95d72f2edd604bcfd4e2d9ac9624f0dd1726b728 Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 1 Aug 2018 18:15:05 +0300 Subject: [PATCH 08/20] Update Client.php --- lib/Gitlab/Client.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Gitlab/Client.php b/lib/Gitlab/Client.php index 0bd3f1eda..c4c38ba52 100644 --- a/lib/Gitlab/Client.php +++ b/lib/Gitlab/Client.php @@ -84,9 +84,8 @@ public function __construct($baseUrl, ClientInterface $httpClient = null, array } $httpClient = $httpClient ?: new Curl(); - // todo: rewrite hotfix - /*$httpClient->setTimeout($this->options['timeout']);*/ - /*$httpClient->setVerifyPeer(false);*/ + $httpClient->setTimeout($this->options['timeout']); + $httpClient->setVerifyPeer(false); $this->baseUrl = $baseUrl; $this->httpClient = new HttpClient($this->baseUrl, $this->options, $httpClient); From 018c434246013ec662c6ac99dd1af09a7d381adb Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 1 Aug 2018 18:15:25 +0300 Subject: [PATCH 09/20] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3c29600a4..4c136375a 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "php": ">=5.3.2", "ext-curl": "*", "ext-xml": "*", - "kriswallsmith/buzz": ">=0.7" + "kriswallsmith/buzz": "^0.7" }, "require-dev": { "phpunit/phpunit": "~4.5" From 3bc6ce129857658d6c4de460d90a5ded019bb710 Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 19 Sep 2018 11:05:45 +0300 Subject: [PATCH 10/20] Update Issues.php --- lib/Gitlab/Api/Issues.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Gitlab/Api/Issues.php b/lib/Gitlab/Api/Issues.php index 0387fd190..b28561157 100644 --- a/lib/Gitlab/Api/Issues.php +++ b/lib/Gitlab/Api/Issues.php @@ -28,7 +28,14 @@ public function all($project_id = null, $page = 1, $per_page = self::PER_PAGE, a */ public function show($project_id, $issue_id) { - return $this->get($this->getProjectPath($project_id, 'issues?iid='.$this->encodePath($issue_id))); + if(is_array($issue_id)) { + $issue_id = array_map(function($item) { return $this->encodePath($item); }, $issue_id); + $issue_id = 'iid[]=' . join('iid[]=', $issue_id); + } else { + $issue_id = 'iid[]=' . $this->encodePath($issue_id); + } + + return $this->get($this->getProjectPath($project_id, 'issues?.$issue_id)); } /** From 353a89d70885b1c8c4b291c8dac4f5e6f9818e11 Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 19 Sep 2018 11:07:28 +0300 Subject: [PATCH 11/20] Update Issues.php --- lib/Gitlab/Api/Issues.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Gitlab/Api/Issues.php b/lib/Gitlab/Api/Issues.php index b28561157..12de7fe9e 100644 --- a/lib/Gitlab/Api/Issues.php +++ b/lib/Gitlab/Api/Issues.php @@ -35,7 +35,7 @@ public function show($project_id, $issue_id) $issue_id = 'iid[]=' . $this->encodePath($issue_id); } - return $this->get($this->getProjectPath($project_id, 'issues?.$issue_id)); + return $this->get($this->getProjectPath($project_id, 'issues?'.$issue_id)); } /** From 101a41346dbba561c15e9957fea7248b8cde4059 Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 19 Sep 2018 11:25:50 +0300 Subject: [PATCH 12/20] Update Issues.php --- lib/Gitlab/Api/Issues.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Gitlab/Api/Issues.php b/lib/Gitlab/Api/Issues.php index 12de7fe9e..fe4a67978 100644 --- a/lib/Gitlab/Api/Issues.php +++ b/lib/Gitlab/Api/Issues.php @@ -30,11 +30,11 @@ public function show($project_id, $issue_id) { if(is_array($issue_id)) { $issue_id = array_map(function($item) { return $this->encodePath($item); }, $issue_id); - $issue_id = 'iid[]=' . join('iid[]=', $issue_id); + $issue_id = 'iids[]=' . join('iids[]=', $issue_id); } else { - $issue_id = 'iid[]=' . $this->encodePath($issue_id); + $issue_id = 'iids[]=' . $this->encodePath($issue_id); } - + return $this->get($this->getProjectPath($project_id, 'issues?'.$issue_id)); } From 35303e763c0fb6e8bcc7d5334b439924cfeba74d Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 19 Sep 2018 12:18:38 +0300 Subject: [PATCH 13/20] Update Issue.php --- lib/Gitlab/Model/Issue.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Gitlab/Model/Issue.php b/lib/Gitlab/Model/Issue.php index 86c7e2add..99d2d0528 100644 --- a/lib/Gitlab/Model/Issue.php +++ b/lib/Gitlab/Model/Issue.php @@ -39,6 +39,8 @@ class Issue extends AbstractModel implements Noteable 'updated_at', 'created_at', 'project', + 'time_stats', + 'due_date', 'state' ); @@ -81,8 +83,7 @@ public function __construct(Project $project, $id = null, Client $client = null) public function show() { $data = $this->api('issues')->show($this->project->id, $this->id); - - return static::fromArray($this->getClient(), $this->project, $data); + return static::fromArray($this->getClient(), $this->project, isset($data[0]) ? $data[0] : []); } /** From 9addabcf197c08c676af6783ba7ec483e959565a Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 19 Sep 2018 12:18:56 +0300 Subject: [PATCH 14/20] Update Issues.php --- lib/Gitlab/Api/Issues.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Gitlab/Api/Issues.php b/lib/Gitlab/Api/Issues.php index fe4a67978..b5bf1a63d 100644 --- a/lib/Gitlab/Api/Issues.php +++ b/lib/Gitlab/Api/Issues.php @@ -38,6 +38,14 @@ public function show($project_id, $issue_id) return $this->get($this->getProjectPath($project_id, 'issues?'.$issue_id)); } + public function time_estimate($project_id, $issue_id, $duration = '1h30m') { + return $this->post($this->getProjectPath($project_id, 'issues/' . $this->encodePath($issue_id) . '/time_estimate?duration=' . $duration), []); + } + + public function add_spent_time($project_id, $issue_id, $duration = '1h30m') { + return $this->post($this->getProjectPath($project_id, 'issues/' . $this->encodePath($issue_id) . '/add_spent_time?duration=' . $duration), []); + } + /** * @param int $project_id * @param array $params From 8a69f47106d3c106e801d89cbf8096d3f3b1adaf Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 19 Sep 2018 14:36:20 +0300 Subject: [PATCH 15/20] Update Project.php --- lib/Gitlab/Model/Project.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Gitlab/Model/Project.php b/lib/Gitlab/Model/Project.php index 44fa9a7ee..c984fbbcd 100644 --- a/lib/Gitlab/Model/Project.php +++ b/lib/Gitlab/Model/Project.php @@ -733,11 +733,12 @@ public function mergeMergeRequest($id) /** * @param int $page * @param int $per_page + * @param array $params * @return Issue[] */ - public function issues($page = 1, $per_page = Api::PER_PAGE) + public function issues($page = 1, $per_page = Api::PER_PAGE, $params = []) { - $data = $this->api('issues')->all($this->id, $page, $per_page); + $data = $this->api('issues')->all($this->id, $page, $per_page, $params); $issues = array(); foreach ($data as $issue) { From 8796dcdd6bc66f25c5d49d01731abbad3f3297ba Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 19 Sep 2018 14:43:05 +0300 Subject: [PATCH 16/20] Update HttpClient.php --- lib/Gitlab/HttpClient/HttpClient.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Gitlab/HttpClient/HttpClient.php b/lib/Gitlab/HttpClient/HttpClient.php index 7a84bfb43..6ee18eac2 100644 --- a/lib/Gitlab/HttpClient/HttpClient.php +++ b/lib/Gitlab/HttpClient/HttpClient.php @@ -3,13 +3,12 @@ use Buzz\Client\ClientInterface; use Buzz\Listener\ListenerInterface; use Buzz\Message\Form\FormUpload; - use Gitlab\Exception\ErrorException; use Gitlab\Exception\RuntimeException; use Gitlab\HttpClient\Listener\ErrorListener; +use Gitlab\HttpClient\Message\FormRequest; use Gitlab\HttpClient\Message\Request; use Gitlab\HttpClient\Message\Response; -use Gitlab\HttpClient\Message\FormRequest; /** * Performs requests on Gitlab API. API documentation should be self-explanatory. @@ -108,6 +107,8 @@ public function get($path, array $parameters = array(), array $headers = array() $path .= (false === strpos($path, '?') ? '?' : '&').http_build_query($parameters, '', '&'); } + $path = preg_replace("/%5B([0-9]+)%5D\=/", "[]=", $path); + return $this->request($path, array(), 'GET', $headers); } From 5c2615ca204157486271a2de45597a3d3b5f4669 Mon Sep 17 00:00:00 2001 From: d3n4 Date: Wed, 17 Jul 2019 16:24:10 +0300 Subject: [PATCH 17/20] Update AbstractApi.php --- lib/Gitlab/Api/AbstractApi.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Gitlab/Api/AbstractApi.php b/lib/Gitlab/Api/AbstractApi.php index f181bf762..a67974a98 100644 --- a/lib/Gitlab/Api/AbstractApi.php +++ b/lib/Gitlab/Api/AbstractApi.php @@ -21,7 +21,7 @@ abstract class AbstractApi implements ApiInterface * * @var Client */ - protected $client; + public $client; /** * @param Client $client @@ -111,7 +111,7 @@ public function delete($path, array $parameters = array(), $requestHeaders = arr * @param string $path * @return string */ - protected function getProjectPath($id, $path) + public function getProjectPath($id, $path) { return 'projects/'.$this->encodePath($id).'/'.$path; } @@ -120,7 +120,7 @@ protected function getProjectPath($id, $path) * @param string $path * @return string */ - protected function encodePath($path) + public function encodePath($path) { $path = rawurlencode($path); From aba5cf508699e88355b8bd05b54ccf619119c81c Mon Sep 17 00:00:00 2001 From: d3n4 Date: Tue, 6 Aug 2019 14:39:17 +0300 Subject: [PATCH 18/20] Update HttpClient.php --- lib/Gitlab/HttpClient/HttpClient.php | 55 +++++++++++++++------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/lib/Gitlab/HttpClient/HttpClient.php b/lib/Gitlab/HttpClient/HttpClient.php index 6ee18eac2..2660ab3b7 100644 --- a/lib/Gitlab/HttpClient/HttpClient.php +++ b/lib/Gitlab/HttpClient/HttpClient.php @@ -22,8 +22,8 @@ class HttpClient implements HttpClientInterface * @var array */ protected $options = array( - 'user_agent' => 'php-gitlab-api (http://github.com/m4tthumphrey/php-gitlab-api)', - 'timeout' => 10, + 'user_agent' => 'php-gitlab-api (http://github.com/m4tthumphrey/php-gitlab-api)', + 'timeout' => 10, ); /** @@ -59,7 +59,7 @@ public function __construct($baseUrl, array $options, ClientInterface $client) { $this->baseUrl = $baseUrl; $this->options = array_merge($this->options, $options); - $this->client = $client; + $this->client = $client; $this->addListener(new ErrorListener($this->options)); @@ -104,7 +104,7 @@ public function addListener(ListenerInterface $listener) public function get($path, array $parameters = array(), array $headers = array()) { if (0 < count($parameters)) { - $path .= (false === strpos($path, '?') ? '?' : '&').http_build_query($parameters, '', '&'); + $path .= (false === strpos($path, '?') ? '?' : '&') . http_build_query($parameters, '', '&'); } $path = preg_replace("/%5B([0-9]+)%5D\=/", "[]=", $path); @@ -149,37 +149,40 @@ public function put($path, array $parameters = array(), array $headers = array() */ public function request($path, array $parameters = array(), $httpMethod = 'GET', array $headers = array(), array $files = array()) { - $path = trim($this->baseUrl.$path, '/'); + $ckey = md5(json_encode([$path, $parameters, $httpMethod, $headers])); + return \Cache::remember($ckey, 3600, function () use($ckey, $path, $parameters, $httpMethod, $headers, $files) { + $path = trim($this->baseUrl . $path, '/'); - $request = $this->createRequest($httpMethod, $path, $parameters, $headers, $files); + $request = $this->createRequest($httpMethod, $path, $parameters, $headers, $files); - $hasListeners = 0 < count($this->listeners); - if ($hasListeners) { - foreach ($this->listeners as $listener) { - $listener->preSend($request); + $hasListeners = 0 < count($this->listeners); + if ($hasListeners) { + foreach ($this->listeners as $listener) { + $listener->preSend($request); + } } - } - $response = new Response(); + $response = new Response(); - try { - $this->client->send($request, $response); - } catch (\LogicException $e) { - throw new ErrorException($e->getMessage()); - } catch (\RuntimeException $e) { - throw new RuntimeException($e->getMessage()); - } + try { + $this->client->send($request, $response); + } catch (\LogicException $e) { + throw new ErrorException($e->getMessage()); + } catch (\RuntimeException $e) { + throw new RuntimeException($e->getMessage()); + } - $this->lastRequest = $request; - $this->lastResponse = $response; + $this->lastRequest = $request; + $this->lastResponse = $response; - if ($hasListeners) { - foreach ($this->listeners as $listener) { - $listener->postSend($request, $response); + if ($hasListeners) { + foreach ($this->listeners as $listener) { + $listener->postSend($request, $response); + } } - } - return $response; + return $response; + }); } /** From bf9d35ef77bd6abe7f1262900857482ec08e2669 Mon Sep 17 00:00:00 2001 From: d3n4 Date: Thu, 8 Aug 2019 10:07:12 +0300 Subject: [PATCH 19/20] Update HttpClient.php --- lib/Gitlab/HttpClient/HttpClient.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Gitlab/HttpClient/HttpClient.php b/lib/Gitlab/HttpClient/HttpClient.php index 2660ab3b7..fdf4656ec 100644 --- a/lib/Gitlab/HttpClient/HttpClient.php +++ b/lib/Gitlab/HttpClient/HttpClient.php @@ -150,7 +150,8 @@ public function put($path, array $parameters = array(), array $headers = array() public function request($path, array $parameters = array(), $httpMethod = 'GET', array $headers = array(), array $files = array()) { $ckey = md5(json_encode([$path, $parameters, $httpMethod, $headers])); - return \Cache::remember($ckey, 3600, function () use($ckey, $path, $parameters, $httpMethod, $headers, $files) { + + $getData = function () use($ckey, $path, $parameters, $httpMethod, $headers, $files) { $path = trim($this->baseUrl . $path, '/'); $request = $this->createRequest($httpMethod, $path, $parameters, $headers, $files); @@ -182,7 +183,13 @@ public function request($path, array $parameters = array(), $httpMethod = 'GET', } return $response; - }); + }; + + if(\Illuminate\Support\Facades\Request::header('Cache-Control') === 'no-cache') { + return $getData(); + } + + return \Cache::remember($ckey, 120, $getData); } /** From c76ebcf77be8647ca712f8dca4b980496ed66710 Mon Sep 17 00:00:00 2001 From: d3n4 Date: Thu, 8 Aug 2019 10:15:09 +0300 Subject: [PATCH 20/20] Update HttpClient.php --- lib/Gitlab/HttpClient/HttpClient.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Gitlab/HttpClient/HttpClient.php b/lib/Gitlab/HttpClient/HttpClient.php index fdf4656ec..f59d41dad 100644 --- a/lib/Gitlab/HttpClient/HttpClient.php +++ b/lib/Gitlab/HttpClient/HttpClient.php @@ -186,7 +186,9 @@ public function request($path, array $parameters = array(), $httpMethod = 'GET', }; if(\Illuminate\Support\Facades\Request::header('Cache-Control') === 'no-cache') { - return $getData(); + $_data = $getData(); + \Cache::put($ckey, $_data, 120); + return $_data; } return \Cache::remember($ckey, 120, $getData);