Add relatedCollection default

This commit is contained in:
fogelito 2025-01-15 10:13:30 +02:00
parent f54684133d
commit bbeb9d4719

View file

@ -136,6 +136,9 @@ class Databases extends Action
$options = $attribute->getAttribute('options', []);
$project = $dbForPlatform->getDocument('projects', $projectId);
$relatedAttribute = new Document();
$relatedCollection = new Document();
try {
switch ($type) {
case Database::VAR_RELATIONSHIP:
@ -175,7 +178,7 @@ class Databases extends Action
if ($e instanceof DatabaseException) {
$attribute->setAttribute('error', $e->getMessage());
if (isset($relatedAttribute)) {
if (! $relatedAttribute->isEmpty()) {
$relatedAttribute->setAttribute('error', $e->getMessage());
}
}
@ -186,7 +189,7 @@ class Databases extends Action
$attribute->setAttribute('status', 'failed')
);
if (isset($relatedAttribute)) {
if (! $relatedAttribute->isEmpty()) {
$dbForProject->updateDocument(
'attributes',
$relatedAttribute->getId(),
@ -198,7 +201,7 @@ class Databases extends Action
} finally {
$this->trigger($database, $collection, $attribute, $project, $projectId, $events);
if ($type === Database::VAR_RELATIONSHIP && $options['twoWay']) {
if (! $relatedCollection->isEmpty()) {
$dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $relatedCollection->getId());
}
@ -364,7 +367,7 @@ class Databases extends Action
} finally {
$dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId);
if (!$relatedCollection->isEmpty() && !$relatedAttribute->isEmpty()) {
if (! $relatedCollection->isEmpty()) {
$dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $relatedCollection->getId());
}
}