Skip to content

Commit

Permalink
fix: hint table for columns for sharded queries
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <[email protected]>
  • Loading branch information
juliusknorr committed Jan 10, 2025
1 parent 837fecc commit b62092d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/Mount/CollectiveFolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OC\Files\Storage\Wrapper\Jail;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OCA\Collectives\ACL\ACLStorageWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Folder;
use OCP\Files\InvalidPathException;
Expand Down Expand Up @@ -149,12 +150,12 @@ private function getJailPath(int $folderId): string {
/**
* @throws NotFoundException
*/
private function getRootFolderStorageId(): int {
private function getFolderRootId(): int {
if ($this->rootFolderStorageId === null) {
$qb = $this->connection->getQueryBuilder();

$qb->select('fileid')
->from('filecache')
$qb->select('f.fileid')
->from('filecache', 'f')
->where($qb->expr()->eq('storage', $qb->createNamedParameter($this->getRootFolder()->getStorage()->getCache()->getNumericStorageId())))
->andWhere($qb->expr()->eq('path_hash', $qb->createNamedParameter(md5($this->getRootPath()))));

Expand Down Expand Up @@ -194,13 +195,12 @@ public function getLandingPagePath(string $path, string $lang): string {
public function getFolderFileCache(int $id, string $name): array {
$qb = $this->connection->getQueryBuilder();
$qb->select(
'co.id AS folder_id', 'fileid', 'storage', 'path', 'fc.name AS name',
'mimetype', 'mimepart', 'size', 'mtime', 'storage_mtime', 'etag', 'encrypted', 'parent', 'fc.permissions AS permissions')
'co.id AS folder_id', 'fc.fileid', 'fc.storage', 'fc.path', 'fc.name AS name',
'fc.mimetype', 'fc.mimepart', 'fc.size', 'fc.mtime', 'fc.storage_mtime', 'fc.etag', 'fc.encrypted', 'fc.parent', 'fc.permissions AS permissions')
->from('collectives', 'co')
->leftJoin('co', 'filecache', 'fc', $qb->expr()->andX(
// concat with empty string to work around missing cast to string
$qb->expr()->eq('fc.name', $qb->func()->concat('co.id', $qb->expr()->literal(''))),
$qb->expr()->eq('parent', $qb->createNamedParameter($this->getRootFolderStorageId()))))
$qb->expr()->eq('fc.name', $query->expr()->castColumn('co.id', IQueryBuilder::PARAM_STR)),

Check failure on line 202 in lib/Mount/CollectiveFolderManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedVariable

lib/Mount/CollectiveFolderManager.php:202:32: UndefinedVariable: Cannot find referenced variable $query (see https://psalm.dev/024)
$qb->expr()->eq('fc.parent', $qb->createNamedParameter($this->getFolderRootId()))))
->where($qb->expr()->eq('co.id', $qb->createNamedParameter($id)));
$cache = $qb->execute()->fetch();
$cache['mount_point'] = $name;
Expand Down

0 comments on commit b62092d

Please sign in to comment.