Browse Source

Fixed relation data GC + PostgreSQL bug

https://github.com/craftcms/cms/issues/9905#issuecomment-1478490012
pull/12955/head
brandonkelly 2 years ago
parent
commit
df12e22582
No known key found for this signature in database GPG Key ID: 5E86D0CED64C7093
  1. 4
      CHANGELOG.md
  2. 10
      src/services/Gc.php

4
CHANGELOG.md

@ -1,5 +1,9 @@
# Release Notes for Craft CMS 3.x
## Unreleased
- Fixed a bug where relation data was getting deleted when running garbage collection on PostgreSQL. ([#9905](https://github.com/craftcms/cms/issues/9905))
## 3.8.4 - 2023-03-20
- The `|json_encode` Twig filter now calls `craft\helpers\Json::encode()` internally, improving error handling. ([#12919](https://github.com/craftcms/cms/issues/12919))

10
src/services/Gc.php

@ -364,7 +364,9 @@ SQL;
DELETE FROM $relationsTable
USING $relationsTable [[r]]
LEFT JOIN $elementsTable [[e]] ON [[e.id]] = [[r.targetId]]
WHERE [[e.id]] IS NULL
WHERE
$relationsTable.[[id]] = [[r.id]] AND
[[e.id]] IS NULL
SQL;
}
@ -390,8 +392,10 @@ SQL;
DELETE FROM $structureElementsTable
USING $structureElementsTable [[se]]
LEFT JOIN $elementsTable [[e]] ON [[e.id]] = [[se.elementId]]
WHERE $structureElementsTable.[[id]] = [[se.id]] AND
[[se.elementId]] IS NOT NULL AND [[e.id]] IS NULL
WHERE
$structureElementsTable.[[id]] = [[se.id]] AND
[[se.elementId]] IS NOT NULL AND
[[e.id]] IS NULL
SQL;
}

Loading…
Cancel
Save