From a5384b74665d8ffa714b8543b026069017dd91d5 Mon Sep 17 00:00:00 2001 From: Junade Date: Tue, 3 Oct 2017 17:59:59 +0100 Subject: [PATCH 1/5] Correct input types for (Bypass) Cache on Cookie --- src/Configurations/PageRulesActions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Configurations/PageRulesActions.php b/src/Configurations/PageRulesActions.php index de28b45..cdb03c8 100644 --- a/src/Configurations/PageRulesActions.php +++ b/src/Configurations/PageRulesActions.php @@ -40,7 +40,7 @@ class PageRulesActions implements Configurations ]); } - public function setBypassCacheOnCookie(bool $value) + public function setBypassCacheOnCookie(string $value) { if (preg_match('/^([a-zA-Z0-9\.=|_*-]+)$/i', $value) < 1) { throw new ConfigurationsException("Invalid cookie string."); @@ -76,7 +76,7 @@ class PageRulesActions implements Configurations ]); } - public function setCacheOnCookie(bool $value) + public function setCacheOnCookie(string $value) { if (preg_match('/^([a-zA-Z0-9\.=|_*-]+)$/i', $value) < 1) { throw new ConfigurationsException("Invalid cookie string."); From d49028a31ea97922f394188fc34c274a11886753 Mon Sep 17 00:00:00 2001 From: Junade Ali Date: Tue, 3 Oct 2017 18:09:07 +0100 Subject: [PATCH 2/5] Updated DNSTest style. --- tests/Endpoints/DNSTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Endpoints/DNSTest.php b/tests/Endpoints/DNSTest.php index 3035b5b..66eb9d9 100644 --- a/tests/Endpoints/DNSTest.php +++ b/tests/Endpoints/DNSTest.php @@ -93,13 +93,13 @@ class DNSTest extends TestCase $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); $mock->method('put')->willReturn($response); - $details = array( + $details = [ 'type' => 'A', 'name' => "example.com", 'content' => "1.2.3.4", 'ttl' => 120, 'proxied' => false, - ); + ]; $mock->expects($this->once()) ->method('put') From 566ab3fc705f319fc44b959f7a60583b935c3fbe Mon Sep 17 00:00:00 2001 From: Linus Metzler Date: Tue, 3 Oct 2017 21:16:58 +0200 Subject: [PATCH 3/5] Don't run json_encode Guzzle takes care of this thanks to its JSON middleware --- src/Adapter/Guzzle.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Adapter/Guzzle.php b/src/Adapter/Guzzle.php index 205ff84..bdbddcd 100644 --- a/src/Adapter/Guzzle.php +++ b/src/Adapter/Guzzle.php @@ -67,13 +67,11 @@ class Guzzle implements Adapter */ public function put(String $uri, array $headers = [], array $body = []): ResponseInterface { - $jsonBody = json_encode($body); - $response = $this->client->put( $uri, [ 'headers' => $headers, - 'json' => $jsonBody + 'json' => $body ] ); @@ -86,13 +84,11 @@ class Guzzle implements Adapter */ public function patch(String $uri, array $headers = [], array $body = []): ResponseInterface { - $jsonBody = json_encode($body); - $response = $this->client->patch( $uri, [ 'headers' => $headers, - 'json' => $jsonBody + 'json' => $body ] ); From 70ee68f755bcebf1b2ef18a4876183e7b5d857e6 Mon Sep 17 00:00:00 2001 From: Linus Metzler Date: Thu, 5 Oct 2017 14:44:09 +0200 Subject: [PATCH 4/5] fix the test --- tests/Adapter/GuzzleTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Adapter/GuzzleTest.php b/tests/Adapter/GuzzleTest.php index a5e16e0..ba4d58e 100644 --- a/tests/Adapter/GuzzleTest.php +++ b/tests/Adapter/GuzzleTest.php @@ -58,7 +58,7 @@ class GuzzleTest extends TestCase $this->assertEquals("application/json", $headers["Content-Type"][0]); $body = json_decode($response->getBody()); - $this->assertEquals("Testing a PUT request.", json_decode($body->json)->{"X-Put-Test"}); + $this->assertEquals("Testing a PUT request.", $body->json->{"X-Put-Test"}); } public function testPatch() @@ -73,7 +73,7 @@ class GuzzleTest extends TestCase $this->assertEquals("application/json", $headers["Content-Type"][0]); $body = json_decode($response->getBody()); - $this->assertEquals("Testing a PATCH request.", json_decode($body->json)->{"X-Patch-Test"}); + $this->assertEquals("Testing a PATCH request.", $body->json->{"X-Patch-Test"}); } public function testDelete() From a909f3780e55ed0eb9901170c9ca22ac66d275b9 Mon Sep 17 00:00:00 2001 From: Mert Oturak <14320594+MertOtrk@users.noreply.github.com> Date: Thu, 12 Oct 2017 03:42:35 +0300 Subject: [PATCH 5/5] About cache - 1107 Error code --- src/Endpoints/Zones.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Endpoints/Zones.php b/src/Endpoints/Zones.php index 6a63f92..da9ddfe 100644 --- a/src/Endpoints/Zones.php +++ b/src/Endpoints/Zones.php @@ -119,9 +119,9 @@ class Zones implements API return false; } - public function cachePurge(string $zoneID, array $files = [], array $tags = []): bool + public function cachePurge(string $zoneID, array $files = null, array $tags = null): bool { - if (empty($files) && empty($tags)) { + if (is_null($files) && is_null($tags)) { throw new EndpointException("No files or tags to purge."); }