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
I have an issue where relations of a propagated entry are affecting results in other sites.
I have a Craft installation with 10 sites and a section set to manual propagation. One entry is propagated to only one site. However, for some reason, there is a row for this entry in the relations table for every site:
The entry only exists in the site with id 3, the relation to targetId594 is the real one that's visible in the backend. The entry doesn't exist in any other sites, but the additional rows with targetId693 are still there. Not sure why, possibly due to #14347 or #13956. In any case, this can apparently happen in some scenarios.
Now I'm querying based on relations for that entry:
Now, the problem is that this query is returning the entry with ID 692, even though those aren't related in this site. I've checked the generated SQL query for the jobStores field, it looks seem to take the siteId into account:
WHERE (`targets1`.`targetId`=4426) AND (`targets1`.`fieldId`=6))) AND (((`elements`.`enabled`=TRUE) AND (`elements_sites`.`enabled`=TRUE)) AND (`entries`.`postDate`<='2024-02-09 17:47:59') AND ((`entries`.`expiryDate` IS NULL) OR (`entries`.`expiryDate`>'2024-02-09 17:47:59'))) AND (`elements`.`archived`=FALSE) AND (`elements`.`dateDeleted` IS NULL) AND (`elements`.`draftId` IS NULL) AND (`elements`.`revisionId` IS NULL)
Steps to reproduce
It's complicated, see above.
Expected behavior
Shouldn't the query always take the site specified in the query into account? Not sure if this has any unintended side effects, for example if relations aren't stored on a per-site basis.
If every case where relations remain in the relations table (like #14347 and #13956) was fixed, this problem might disappear. Though I'm sure there are other scenarios. I don't believe the entry in question was propagated to all sites and then deleted again, so the 10 rows in the database listed above must have been created in some other way.
As a workaround, maybe Craft can provide a console command to clean up those orphaned relations?
I'm not confident I fully understand the problem leading to the incorrect results here, correct me if I'm wrong …
Craft CMS version
4.7.2.1
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered:
It's actually related to this one: #14258 and there's already a PR for it. If you have a sec, it would be great if you could check if that PR fixes things for you.
You can do that by changing your craftcms/cms requirement in composer.json to dev-develop#cec95d8e7426d94d1eee327fa6dc4d922851df0b as 4.7.2.1
What happened?
Description
I have an issue where relations of a propagated entry are affecting results in other sites.
I have a Craft installation with 10 sites and a section set to manual propagation. One entry is propagated to only one site. However, for some reason, there is a row for this entry in the relations table for every site:
The entry only exists in the site with id
3
, the relation totargetId
594
is the real one that's visible in the backend. The entry doesn't exist in any other sites, but the additional rows withtargetId
693
are still there. Not sure why, possibly due to #14347 or #13956. In any case, this can apparently happen in some scenarios.Now I'm querying based on relations for that entry:
$site
is the site with ID3
.jobsStores
is the field with ID6
.$store
is the entry with ID693
.Now, the problem is that this query is returning the entry with ID
692
, even though those aren't related in this site. I've checked the generated SQL query for thejobStores
field, it looks seem to take thesiteId
into account:Steps to reproduce
It's complicated, see above.
Expected behavior
Shouldn't the query always take the
site
specified in the query into account? Not sure if this has any unintended side effects, for example if relations aren't stored on a per-site basis.If every case where relations remain in the
relations
table (like #14347 and #13956) was fixed, this problem might disappear. Though I'm sure there are other scenarios. I don't believe the entry in question was propagated to all sites and then deleted again, so the 10 rows in the database listed above must have been created in some other way.As a workaround, maybe Craft can provide a console command to clean up those orphaned relations?
I'm not confident I fully understand the problem leading to the incorrect results here, correct me if I'm wrong …
Craft CMS version
4.7.2.1
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: