Skip to content

Commit f98fe49

Browse files
committed
fixup! Fix SQL statement and provider method call
1 parent 1b36373 commit f98fe49

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

lib/private/Collaboration/Resources/Manager.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ public function getCollectionForUser(int $id, ?IUser $user): ICollection {
8585
$query->select('*')
8686
->from(self::TABLE_COLLECTIONS, 'c')
8787
->leftJoin(
88-
'a', self::TABLE_ACCESS_CACHE, 'a',
88+
'c', self::TABLE_ACCESS_CACHE, 'a',
8989
$query->expr()->andX(
90-
$query->expr()->eq('c.id', 'a.resource_id'),
90+
$query->expr()->eq('c.id', 'a.collection_id'),
9191
$query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
9292
)
9393
)
@@ -103,10 +103,10 @@ public function getCollectionForUser(int $id, ?IUser $user): ICollection {
103103
$access = $row['access'] === null ? null : (bool) $row['access'];
104104
if ($user instanceof IUser) {
105105
$access = [$user->getUID() => $access];
106-
return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $access, null);
106+
return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $user, null);
107107
}
108108

109-
return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], [], $access);
109+
return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $user, $access);
110110
}
111111

112112
/**
@@ -122,16 +122,16 @@ public function searchCollections(IUser $user, string $filter, int $limit = 50,
122122
$userId = $user instanceof IUser ? $user->getUID() : '';
123123

124124
$query->select('c.*', 'a.access')
125-
->from(self::TABLE_COLLECTIONS)
125+
->from(self::TABLE_COLLECTIONS, 'c')
126126
->leftJoin(
127-
'r', self::TABLE_ACCESS_CACHE, 'a',
127+
'c', self::TABLE_ACCESS_CACHE, 'a',
128128
$query->expr()->andX(
129-
$query->expr()->eq('c.id', 'a.resource_id'),
129+
$query->expr()->eq('c.id', 'a.collection_id'),
130130
$query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
131131
)
132132
)
133133
->where($query->expr()->iLike('c.name', $query->createNamedParameter($filter, IQueryBuilder::PARAM_STR)))
134-
->andWhere($query->expr()->neq('a.access', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
134+
->andWhere($query->expr()->eq('a.access', $query->createNamedParameter(1, IQueryBuilder::PARAM_INT)))
135135
->orderBy('c.id')
136136
->setMaxResults($limit)
137137
->setFirstResult($start);
@@ -236,7 +236,7 @@ public function getResourcesByCollectionForUser(ICollection $collection, ?IUser
236236
->leftJoin(
237237
'r', self::TABLE_ACCESS_CACHE, 'a',
238238
$query->expr()->andX(
239-
$query->expr()->eq('r.id', 'a.resource_id'),
239+
$query->expr()->eq('r.resource_id', 'a.resource_id'),
240240
$query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
241241
)
242242
)

0 commit comments

Comments
 (0)