From d5d766cbf46d22c2997bc004096f484751147ffb Mon Sep 17 00:00:00 2001 From: Lukas Rosenstock Date: Fri, 15 May 2026 14:06:15 +0000 Subject: [PATCH] Added getRevision() helper function, refactored revision constant --- CloudObjects/SDK/CloudObject.php | 9 ++++++++- CloudObjects/SDK/Constants.php | 13 +++++++++++++ CloudObjects/SDK/ObjectRetriever.php | 8 +++----- 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 CloudObjects/SDK/Constants.php diff --git a/CloudObjects/SDK/CloudObject.php b/CloudObjects/SDK/CloudObject.php index c4da858..70278d0 100644 --- a/CloudObjects/SDK/CloudObject.php +++ b/CloudObjects/SDK/CloudObject.php @@ -157,6 +157,13 @@ class CloudObject { } return $this->retriever->getObjectNode($coid); - } + } + + /** + * Get the revision of the object. + */ + public function getRevision() : string { + return $this->getString(Constants::PROPERTY_REVISION); + } } diff --git a/CloudObjects/SDK/Constants.php b/CloudObjects/SDK/Constants.php new file mode 100644 index 0000000..12ab01d --- /dev/null +++ b/CloudObjects/SDK/Constants.php @@ -0,0 +1,13 @@ +options = array_merge([ @@ -479,7 +477,7 @@ class ObjectRetriever implements CustomCacheAndLogInterface { } if (!isset($fileData) - || $fileRevision!=$object->getProperty(self::REVISION_PROPERTY)->getValue()) { + || $fileRevision !== $object->getProperty(Constants::PROPERTY_REVISION)->getValue()) { // Does not exist in cache or is outdated, fetch from CloudObjects try { @@ -487,7 +485,7 @@ class ObjectRetriever implements CustomCacheAndLogInterface { .'/'.basename($filename)); $fileContent = $response->getBody()->getContents(); - $fileData = $object->getProperty(self::REVISION_PROPERTY)->getValue().'#'.$fileContent; + $fileData = $object->getProperty(Constants::PROPERTY_REVISION)->getValue().'#'.$fileContent; $this->putIntoCache($cacheId, $fileData, 0); $this->logInfoWithTime('Fetched attachment <'.$filename.'> for <'.$object->getId().'> from Core API ['.$response->getStatusCode().'].', $ts);