Added getRevision() helper function, refactored revision constant

This commit is contained in:
2026-05-15 14:06:15 +00:00
parent 06df8b0be1
commit d5d766cbf4
3 changed files with 24 additions and 6 deletions

View File

@@ -32,9 +32,7 @@ class ObjectRetriever implements CustomCacheAndLogInterface {
private $defaultReader;
const CO_API_URL = 'https://od.coid.link/';
const REVISION_PROPERTY = 'coid://cloudobjects.io/isAtRevision';
public function __construct($options = []) {
// Merge options with defaults
$this->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);