From 8da748a63026c7cd4d3b583ec2be16f328975033 Mon Sep 17 00:00:00 2001 From: Wilco Louwerse Date: Tue, 30 Jan 2024 10:30:25 +0100 Subject: [PATCH 1/3] Allow syncService->getSourceId $endpoint to be null --- api/src/Service/SynchronizationService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/Service/SynchronizationService.php b/api/src/Service/SynchronizationService.php index 481f56ede..956e6a91f 100644 --- a/api/src/Service/SynchronizationService.php +++ b/api/src/Service/SynchronizationService.php @@ -1516,12 +1516,12 @@ public function aquireObject(string $url, Entity $entity): ?ObjectEntity * A function best used after resourceService->findSourceForUrl and/or before $this->findSyncBySource. * This function will get the uuid / int id from the end of an endpoint. This is the sourceId for a Synchronization. * - * @param string $endpoint The endpoint to get the SourceId from. + * @param string|null $endpoint The endpoint to get the SourceId from. * @param string|null $url The url used as back-up for SourceId if no proper SourceId can be found. * * @return string|null The sourceId, will be equal to $url if end part of the endpoint isn't an uuid or integer. */ - public function getSourceId(string &$endpoint, ?string $url = null): ?string + public function getSourceId(?string &$endpoint, ?string $url = null): ?string { $explodedEndpoint = explode('/', $endpoint); $sourceId = end($explodedEndpoint); From f64a960a51dc1d264c4aa0043dbaec5ca76a0662 Mon Sep 17 00:00:00 2001 From: Wilco Louwerse Date: Tue, 30 Jan 2024 15:27:59 +0100 Subject: [PATCH 2/3] Return sourceId = url for syncService->getSourceId if endpoint = null --- api/src/Service/SynchronizationService.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/src/Service/SynchronizationService.php b/api/src/Service/SynchronizationService.php index 956e6a91f..0f9e2dcf6 100644 --- a/api/src/Service/SynchronizationService.php +++ b/api/src/Service/SynchronizationService.php @@ -1523,6 +1523,10 @@ public function aquireObject(string $url, Entity $entity): ?ObjectEntity */ public function getSourceId(?string &$endpoint, ?string $url = null): ?string { + if ($endpoint === null) { + return $url; + } + $explodedEndpoint = explode('/', $endpoint); $sourceId = end($explodedEndpoint); if (Uuid::isValid($sourceId) === true || is_int((int) $sourceId) === true) { From 8b9fe2dd4c745f934c8adc5469c6eb3f199c393d Mon Sep 17 00:00:00 2001 From: Wilco Louwerse Date: Tue, 30 Jan 2024 15:37:25 +0100 Subject: [PATCH 3/3] update docblock --- api/src/Service/SynchronizationService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/Service/SynchronizationService.php b/api/src/Service/SynchronizationService.php index 0f9e2dcf6..b3ef73c37 100644 --- a/api/src/Service/SynchronizationService.php +++ b/api/src/Service/SynchronizationService.php @@ -1519,7 +1519,7 @@ public function aquireObject(string $url, Entity $entity): ?ObjectEntity * @param string|null $endpoint The endpoint to get the SourceId from. * @param string|null $url The url used as back-up for SourceId if no proper SourceId can be found. * - * @return string|null The sourceId, will be equal to $url if end part of the endpoint isn't an uuid or integer. + * @return string|null The sourceId, will be equal to $url if end part of the endpoint isn't an uuid or integer. And will return null if $endpoint & $url ar both null. */ public function getSourceId(?string &$endpoint, ?string $url = null): ?string {