Error when publishing draft on an entry that is cloned/duplicated
Closed this issue · 2 comments
Joobs commented
Craft 3.6.11.1, Preparse 1.2.4
If I clone/duplicate an entry, and then try and publish a draft from that cloned entry I get the following error:
PHP Notice – yii\base\ErrorException
Trying to get property 'id' of non-object
1. in /app/cms/vendor/besteadfast/craft-preparse-field/src/PreparseField.phpat line 118
function (ElementEvent $event) {
if ($event->element->getIsRevision()) {
return;
}
if ($event->element->getId()) {
// Since it's already been saved, we need to fetch the element again.
/** @var Element $element */
$element = Craft::$app->elements->getElementById($event->element->getId(), null, $event->element->siteId);
$key = $element->id . '__' . $element->siteId;
if (!isset($this->preparsedElements['onSave'][$key])) {
$this->preparsedElements['onSave'][$key] = true;
// Still pass the event element here to generate the preparse fields content, not the $element fetched above.
$content = self::$plugin->preparseFieldService->getPreparseFieldsContent($event->element, 'onSave');
if (!empty($content)) {
$this->resetUploads();
I've seen the Trying to get property 'id' of non-object
mentioned in a few other recent issues. Any idea how to fix?
jalendport commented
Hey, just wanted to let you know that we've found a potential solution for this; just want to do some testing and maybe get some additional eyes on it from some people that are much smarter than I am so we don't cause a regression for #66. Look for something early next week 🤞
jalendport commented
Just released version 1.2.5 which fixes this bug 🎉