You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a bug when querying Assets and using includeSubfolders(true). Short story, if the folderId that's passed into folderId() is the root folder of a volume, that folder is omitted from the resulting query.
...I get the expected result, all Assets in the two subfolders. And the query has the correct folderIds in the WHERE: WHERE ((assets.folderId = 11) OR (assets.folderId = 12))....
If I do it on folderId 12, I also get the expected result; only Assets in the subfolder with id 12.
Description
There seems to be a bug when querying Assets and using
includeSubfolders(true)
. Short story, if the folderId that's passed intofolderId()
is the root folder of a volume, that folder is omitted from the resulting query.Steps to reproduce
I have a folder structure like this:
— Volume root folder (folderId: 1)
—— Subfolder (folderid: 11)
——— Another subfolder (folderId: 12)
If I do...
$count = Asset::find()->folderId(1)->includeSubfolders(true)->limit(null)
...only assets in the subfolders are returned, not assets in the root folder itself.
The query generated (using
getRawSql()
) is:The folderIds queried in the WHERE are the two subfolders, not the root folder itself:
WHERE ((
assets.
folderId= 11) OR (
assets.
folderId= 12))...
.If I change the query to...
$count = Asset::find()->folderId(11)->includeSubfolders(true)->limit(null)
...I get the expected result, all Assets in the two subfolders. And the query has the correct folderIds in the WHERE:
WHERE ((
assets.
folderId= 11) OR (
assets.
folderId= 12))...
.If I do it on folderId 12, I also get the expected result; only Assets in the subfolder with id 12.
If I do...
$count = Asset::find()->folderId(1)->includeSubfolders(false)->limit(null)
I get the expected result; only Assets that are in the root folder.
This has been tested both on a local volume and a S3 volume with the same results.
Additional info
The text was updated successfully, but these errors were encountered: