From 574a54c8a1f948f519ee5c701568f481c89ab1ab Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 27 Nov 2022 19:05:00 +0100 Subject: [PATCH 1/7] Remove endpoint url from Trebblle constructor call The endpoint url is unnecessary when instantiating the Trebblle object. --- src/DependencyInjection/TreblleFactory.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/DependencyInjection/TreblleFactory.php b/src/DependencyInjection/TreblleFactory.php index 8bdc3ad..5373c3f 100644 --- a/src/DependencyInjection/TreblleFactory.php +++ b/src/DependencyInjection/TreblleFactory.php @@ -25,7 +25,6 @@ public static function createTreblle( ErrorDataProvider $errorDataProvider ): Treblle { return new Treblle( - $configuration->getEndpointUrl(), $configuration->getApiKey(), $configuration->getProjectId(), $client, From cdb51586871791b01704123228512e37b64c6398 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 27 Nov 2022 19:09:06 +0100 Subject: [PATCH 2/7] Remove endpoint url from Treblle constructor call The endpoint url is unnecessary when instantiating the Treblle object. --- tests/TreblleIntegrationTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/TreblleIntegrationTest.php b/tests/TreblleIntegrationTest.php index 4a1b4d6..f380d50 100644 --- a/tests/TreblleIntegrationTest.php +++ b/tests/TreblleIntegrationTest.php @@ -79,7 +79,6 @@ protected function setUp(): void $this->dataProvider = new DataProvider(new PayloadAnonymizer([])); $this->treblle = new Treblle( - 'http://127.0.0.1', 'my api key', 'my project id', $client, From e38ada8673d464d79fafeafb6e8f5a47030cac1d Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 27 Nov 2022 19:11:09 +0100 Subject: [PATCH 3/7] Change method call from isMasterRequest() to isMainRequest() The method isMasterRequest() has been renamed to isMainRequest(). --- src/DataProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataProvider.php b/src/DataProvider.php index 6ce93c2..ce54092 100644 --- a/src/DataProvider.php +++ b/src/DataProvider.php @@ -41,7 +41,7 @@ public static function getSubscribedEvents(): array public function onKernelRequest(RequestEvent $event): void { - if ($event->isMasterRequest()) { + if ($event->isMainRequest()) { $this->httpRequest = $event->getRequest(); $this->timestampStart = microtime(true); } From f32041f73b596d4d1263a623c5c8a0f89bfe4462 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 28 Nov 2022 18:10:40 +0100 Subject: [PATCH 4/7] Add backward compatibility The method isMainRequest() only exists in Symfony >= 5.3. So we need to check if the method exists before we call it and then do the same for isMasterRequest(). --- src/DataProvider.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/DataProvider.php b/src/DataProvider.php index ce54092..d4e655b 100644 --- a/src/DataProvider.php +++ b/src/DataProvider.php @@ -41,9 +41,19 @@ public static function getSubscribedEvents(): array public function onKernelRequest(RequestEvent $event): void { - if ($event->isMainRequest()) { - $this->httpRequest = $event->getRequest(); - $this->timestampStart = microtime(true); + if (method_exists($event, 'isMainRequest') { //Symfony >= 5.3 + if ($event->isMainRequest()) { + $this->httpRequest = $event->getRequest(); + $this->timestampStart = microtime(true); + } + } + + + if (method_exists($event, 'isMasterRequest') { //Symfony < 5.3 + if ($event->isMasterRequest()) { + $this->httpRequest = $event->getRequest(); + $this->timestampStart = microtime(true); + } } } From a1ab997578518601cee1404c54d099cb5ebb5205 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 28 Nov 2022 18:17:00 +0100 Subject: [PATCH 5/7] Add missing parenthesis. --- src/DataProvider.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/DataProvider.php b/src/DataProvider.php index d4e655b..d4b8668 100644 --- a/src/DataProvider.php +++ b/src/DataProvider.php @@ -41,15 +41,14 @@ public static function getSubscribedEvents(): array public function onKernelRequest(RequestEvent $event): void { - if (method_exists($event, 'isMainRequest') { //Symfony >= 5.3 + if (method_exists($event, 'isMainRequest')) { //Symfony >= 5.3 if ($event->isMainRequest()) { $this->httpRequest = $event->getRequest(); $this->timestampStart = microtime(true); } } - - if (method_exists($event, 'isMasterRequest') { //Symfony < 5.3 + if (method_exists($event, 'isMasterRequest')) { //Symfony < 5.3 if ($event->isMasterRequest()) { $this->httpRequest = $event->getRequest(); $this->timestampStart = microtime(true); From cefe0f309f9e7298c442e9fc4a3249e50da978b0 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 29 Nov 2022 09:59:33 +0100 Subject: [PATCH 6/7] Add early return. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Zoran Antolović --- src/DataProvider.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DataProvider.php b/src/DataProvider.php index d4b8668..167964e 100644 --- a/src/DataProvider.php +++ b/src/DataProvider.php @@ -46,6 +46,7 @@ public function onKernelRequest(RequestEvent $event): void $this->httpRequest = $event->getRequest(); $this->timestampStart = microtime(true); } + return; } if (method_exists($event, 'isMasterRequest')) { //Symfony < 5.3 From 3e7efde0dee78c6d5ce89d97e2c03782ab96e88b Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 29 Nov 2022 11:44:33 +0100 Subject: [PATCH 7/7] Apply coding standards. --- src/DataProvider.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/DataProvider.php b/src/DataProvider.php index 167964e..9bc8309 100644 --- a/src/DataProvider.php +++ b/src/DataProvider.php @@ -41,15 +41,16 @@ public static function getSubscribedEvents(): array public function onKernelRequest(RequestEvent $event): void { - if (method_exists($event, 'isMainRequest')) { //Symfony >= 5.3 + if (method_exists($event, 'isMainRequest')) { // Symfony >= 5.3 if ($event->isMainRequest()) { $this->httpRequest = $event->getRequest(); $this->timestampStart = microtime(true); } - return; + + return; } - if (method_exists($event, 'isMasterRequest')) { //Symfony < 5.3 + if (method_exists($event, 'isMasterRequest')) { // Symfony < 5.3 if ($event->isMasterRequest()) { $this->httpRequest = $event->getRequest(); $this->timestampStart = microtime(true);