diff --git a/lib/Db/TimelineQueryAlbums.php b/lib/Db/TimelineQueryAlbums.php index b39b2826..2d843d86 100644 --- a/lib/Db/TimelineQueryAlbums.php +++ b/lib/Db/TimelineQueryAlbums.php @@ -39,7 +39,7 @@ trait TimelineQueryAlbums $query->select('pa.*', $count)->from('photos_albums', 'pa'); if ($shared) { - $query->innerJoin('pa', 'photos_collaborators', 'pc', $query->expr()->andX( + $query->innerJoin('pa', $this->collaboratorsTable(), 'pc', $query->expr()->andX( $query->expr()->eq('pa.album_id', 'pc.album_id'), $query->expr()->eq('pc.collaborator_id', $query->createNamedParameter($uid)), )); @@ -153,7 +153,7 @@ trait TimelineQueryAlbums // Check in collaborators instead $query = $conn->getQueryBuilder(); - $query->select('album_id')->from('photos_collaborators')->where( + $query->select('album_id')->from($this->collaboratorsTable())->where( $query->expr()->andX( $query->expr()->eq('album_id', $query->createNamedParameter($album['album_id'])), $query->expr()->eq('collaborator_id', $query->createNamedParameter($uid)), @@ -164,4 +164,16 @@ trait TimelineQueryAlbums return $album; } } + + /** Get the name of the collaborators table */ + private function collaboratorsTable() { + // https://github.com/nextcloud/photos/commit/20e3e61ad577014e5f092a292c90a8476f630355 + $appManager = \OC::$server->getAppManager(); + $photosVersion = $appManager->getAppVersion('photos'); + if (version_compare($photosVersion, '2.2.0', '>=')) { + return 'photos_albums_collabs'; + } + + return 'photos_collaborators'; + } } diff --git a/lib/Util.php b/lib/Util.php index 9d7e1e1a..32512589 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -55,7 +55,7 @@ class Util return false; } - $v = $appManager->getAppInfo('photos')['version']; + $v = $appManager->getAppVersion('photos'); return version_compare($v, '1.7.0', '>='); } @@ -81,7 +81,7 @@ class Util return false; } - $v = $appManager->getAppInfo('recognize')['version']; + $v = $appManager->getAppVersion('recognize'); return version_compare($v, '3.0.0-alpha', '>='); }