diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bb5ad41..c50c64d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Fixed a bug where selected image transforms were being forgotten, if the transform changed the file format. ([#588](https://github.com/craftcms/ckeditor/issues/588)) - Fixed a bug where downloadable links’ `download` attributes were sometimes getting set to the value `"true"`. ([#606](https://github.com/craftcms/ckeditor/issues/606)) - Fixed a bug where custom styles weren’t being applied in fullscreen mode. ([#614](https://github.com/craftcms/ckeditor/issues/614)) +- Fixed a bug where entry deletion blockers were factoring in drafts and revisions that referenced the to-be-deleted entry. ([#600](https://github.com/craftcms/ckeditor/issues/600)) - Fixed a styling issue with the Link modal. ([#610](https://github.com/craftcms/ckeditor/issues/610)) ## 5.6.1 - 2026-05-13 diff --git a/src/deletionblockers/ReferenceDeletionBlocker.php b/src/deletionblockers/ReferenceDeletionBlocker.php index 27c6f2d2..8d745e38 100644 --- a/src/deletionblockers/ReferenceDeletionBlocker.php +++ b/src/deletionblockers/ReferenceDeletionBlocker.php @@ -12,6 +12,7 @@ use craft\base\ElementInterface; use craft\ckeditor\Plugin; use craft\db\Query; +use craft\db\Table; use craft\elements\deletionblockers\BaseDeletionBlocker; use craft\helpers\Html; use craft\helpers\StringHelper; @@ -27,9 +28,12 @@ public function init() { if (Craft::$app->getDb()->tableExists(Plugin::TABLE_REFERENCES)) { $this->referenceCount = (new Query()) - ->from(Plugin::TABLE_REFERENCES) + ->from(['ckeditor_references' => Plugin::TABLE_REFERENCES]) + ->leftJoin(['elements' => Table::ELEMENTS], '[[elements.id]] = [[ckeditor_references.sourceId]]') ->where([ 'targetId' => $this->elements->ids()->all(), + 'elements.draftId' => null, + 'elements.revisionId' => null, ]) ->count(); } else {