Fix logic for finding matching attribute
This commit is contained in:
parent
6d96794179
commit
e609954659
|
@ -717,21 +717,21 @@ App::delete('/v1/database/collections/:collectionId/attributes/:attributeId')
|
|||
throw new Exception('Collection not found', 404);
|
||||
}
|
||||
|
||||
$attributes = $collection->getAttributes();
|
||||
/** @var Document[] $attributes */
|
||||
$attributes = $collection->getAttribute('attributes');
|
||||
|
||||
// Search for attribute
|
||||
$attributeIndex = array_search($attributeId, array_column($attributes, '$id'));
|
||||
|
||||
if ($attributeIndex === false) {
|
||||
throw new Exception('Attribute not found', 404);
|
||||
// find attribute in collection
|
||||
$attribute = null;
|
||||
foreach ($attributes as $a) {
|
||||
if ($a->getId() === $attributeId) {
|
||||
$attribute = $a->setAttribute('$collection', $collectionId); // set the collectionId
|
||||
break; // break once attribute is found
|
||||
}
|
||||
}
|
||||
|
||||
$attribute = new Document([\array_merge($attributes[$attributeIndex], [
|
||||
'collectionId' => $collectionId,
|
||||
])]);
|
||||
|
||||
$type = $attribute->getAttribute('type', '');
|
||||
$format = $attribute->getAttribute('format', '');
|
||||
if (\is_null($attribute)) {
|
||||
throw new Exception('Attribute not found', 404);
|
||||
}
|
||||
|
||||
$database
|
||||
->setParam('type', DELETE_TYPE_ATTRIBUTE)
|
||||
|
|
|
@ -7,4 +7,4 @@ else
|
|||
REDIS_BACKEND="redis://${_APP_REDIS_USER}:${_APP_REDIS_PASS}@${_APP_REDIS_HOST}:${_APP_REDIS_PORT}"
|
||||
fi
|
||||
|
||||
QUEUE='v1-database' APP_INCLUDE='/usr/src/code/app/workers/database.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php
|
||||
INTERVAL=0.1 QUEUE='v1-database' APP_INCLUDE='/usr/src/code/app/workers/database.php' php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php
|
Loading…
Reference in a new issue