diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php index 295b78a114..4d2932f955 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php @@ -99,6 +99,17 @@ class XList extends Action throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } + $joins = Query::getJoinQueries($queries, false); + foreach ($joins as $join) { + $col = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $join->getCollection())); + + if ($col->isEmpty() || (!$col->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { + throw new Exception($this->getParentNotFoundException(), params: [$join->getCollection()]); + } + + $join->setCollection('database_' . $database->getSequence() . '_collection_' . $col->getSequence()); + } + $cursor = Query::getCursorQueries($queries, false); $cursor = \reset($cursor);