From 669caebac0f3643c576cf93f55a57244fca890c1 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Mon, 28 Jul 2025 19:05:30 +0530 Subject: [PATCH 1/3] updated the bug of resource key setting --- src/Migration/Cache.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Migration/Cache.php b/src/Migration/Cache.php index 97a01547..4e80abf2 100644 --- a/src/Migration/Cache.php +++ b/src/Migration/Cache.php @@ -34,6 +34,10 @@ public function __construct() */ public function getResourceCacheKey(Resource $resource): string { + if (! $resource->getSequence()) { + $resource->setSequence(uniqid()); + } + $resourceName = $resource->getName(); $keys = []; @@ -84,14 +88,6 @@ public function getResourceCacheKey(Resource $resource): string */ public function add(Resource $resource): void { - if (! $resource->getSequence()) { - $resourceId = uniqid(); - if (isset($this->cache[$resource->getName()][$resourceId])) { - $resourceId = uniqid(); - // todo: $resourceId is not used? - } - $resource->setSequence(uniqid()); - } $key = $this->getResourceCacheKey($resource); if ($resource->getName() == Resource::TYPE_ROW || $resource->getName() == Resource::TYPE_DOCUMENT) { $status = $resource->getStatus(); From 8688096e86c5af678357c6ebdf4a03b3af667603 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Mon, 28 Jul 2025 19:08:42 +0530 Subject: [PATCH 2/3] change getResourceCacheKey to resolveResourceKey to define the behaviour as it is setting and getting => resolving --- src/Migration/Cache.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Migration/Cache.php b/src/Migration/Cache.php index 4e80abf2..e6af70c2 100644 --- a/src/Migration/Cache.php +++ b/src/Migration/Cache.php @@ -32,7 +32,7 @@ public function __construct() * @param Resource $resource * @return string */ - public function getResourceCacheKey(Resource $resource): string + public function resolveResourceCacheKey(Resource $resource): string { if (! $resource->getSequence()) { $resource->setSequence(uniqid()); @@ -88,7 +88,7 @@ public function getResourceCacheKey(Resource $resource): string */ public function add(Resource $resource): void { - $key = $this->getResourceCacheKey($resource); + $key = $this->resolveResourceCacheKey($resource); if ($resource->getName() == Resource::TYPE_ROW || $resource->getName() == Resource::TYPE_DOCUMENT) { $status = $resource->getStatus(); $this->cache[$resource->getName()][$key] = $status; @@ -127,7 +127,7 @@ public function addAll(array $resources): void */ public function update(Resource $resource): void { - $key = $this->getResourceCacheKey($resource); + $key = $this->resolveResourceCacheKey($resource); // if rows then updating the status counter only if ($resource->getName() == Resource::TYPE_ROW || $resource->getName() == Resource::TYPE_DOCUMENT) { if (!isset($this->cache[$resource->getName()][$key])) { @@ -168,7 +168,7 @@ public function updateAll(array $resources): void */ public function remove(Resource $resource): void { - $key = $this->getResourceCacheKey($resource); + $key = $this->resolveResourceCacheKey($resource); if ($resource->getName() == Resource::TYPE_ROW || $resource->getName() == Resource::TYPE_DOCUMENT) { if (! isset($this->cache[$resource->getName()][$key])) { throw new \Exception('Resource does not exist in cache'); From a535cb29710ba9aad094fb01ada1e9f03e285e92 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Mon, 28 Jul 2025 19:11:45 +0530 Subject: [PATCH 3/3] resolved merge conflict --- src/Migration/Cache.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Migration/Cache.php b/src/Migration/Cache.php index 91e58ca1..3651bae7 100644 --- a/src/Migration/Cache.php +++ b/src/Migration/Cache.php @@ -27,11 +27,11 @@ public function __construct() } /** - * Get cache key from resource - * - * @param Resource $resource - * @return string - */ + * Get cache key from resource + * + * @param Resource $resource + * @return string + */ public function resolveResourceCacheKey(Resource $resource): string { if (! $resource->getSequence()) {