diff --git a/src/Plugin.php b/src/Plugin.php index df64fd1e..a22dabb9 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -11,6 +11,7 @@ use craft\base\Element; use craft\ckeditor\web\assets\BaseCkeditorPackageAsset; use craft\ckeditor\web\assets\ckeditor\CkeditorAsset; +use craft\elements\Entry; use craft\elements\NestedElementManager; use craft\events\AssetBundleEvent; use craft\events\ModelEvent; @@ -96,6 +97,22 @@ public function init() foreach ($this->entryManagers($element) as $entryManager) { $entryManager->maintainNestedElements($element, $event->isNew); } + } else { + // if we are resaving, and it's an owner element, + // and all other "standard" conditions are met (see Entry::_shouldSaveRevision()) + // create the revision + if ( + $element instanceof Entry && + !Craft::$app->getRequest()->isConsoleRequest && + $element->getPrimaryOwnerId() === null && + $element->id && + !$element->propagating && + !$element->getIsDraft() && + !$element->getIsRevision() && + $element->getSection()?->enableVersioning + ) { + Craft::$app->getRevisions()->createRevision($element); + } } });