Added getRevision() helper function, refactored revision constant
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user