-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entry title reverts to previous value when publishing multiple drafts #9966
Comments
ok, we could narrow down the faulty behaviour to the autosave functionality for the entry drafts. we disabled it in |
@cruiser12, I noticed the same. It only seems to occur with draft merging. |
Can confirm this also happens for us, although in slightly different circumstances. The difference is we are not using a multisite config, and we've noticed it primarily with entries with Matrix fields. We DO also have Craft version: 3.7.17.1 Happy to provide any additional info. |
Just fixed this for the next release. @chadwells The issue I just fixed is definitely specific to a multi-site entry; if you are seeing a similar issue on a single-site entry, please post a new issue with more details and steps to reproduce. |
Craft 3.7.18 is out now with that fix. |
@brandonkelly I am experiencing this problem in Craft CMS 4 with multi site. Craft CMS: 4.4.7.1 Is it possible this is related to this issue or should I make a new issue for this? |
@jornwildenbeest Please update to the latest 4.4 release as a starting point, and verify you can still reproduce. If so, yes, post a new issue about it with steps to reproduce. Thanks! |
@brandonkelly I traced the issue back to a third party plugin I am using to create the drafts in different languages. This is plugin is using the following code to create the drafts: $sourceEntry = Entry::findOne(['id' => $entryId, 'siteId' => $sourceSiteId, 'status' => null]);
$targetEntry = Entry::findOne(['id' => $entryId, 'siteId' => $destinationSiteId, 'status' => null]);
//TODO Handle different section propagation methods ?
$newTitle = Deepl::getInstance()->api->translateString(
$sourceEntry->title,
$sourceSite->language,
$destinationSite->language
);
$targetEntry->title = $newTitle;
$targetEntry->slug = "";
$newValues = Deepl::getInstance()->mapper->entryMapper($sourceEntry, $targetEntry);
// Save the translated version of the entry as a new draft
/** @var Element|DraftBehavior $element */
$draft = Craft::$app->getDrafts()->createDraft(
$targetEntry,
Craft::$app->getUser()->getIdentity()->id,
'Translation',
'Creating DeepL translation',
);
$draft->setCanonical($targetEntry);
$draft->setScenario(Element::SCENARIO_ESSENTIALS);
$draft->setFieldValues($newValues); Do you know if there is anything wrong with this code that can cause this kind of issue? |
Actually yes. The updated If those attributes are set on the $sourceEntry = Entry::findOne(['id' => $entryId, 'siteId' => $sourceSiteId, 'status' => null]);
$targetEntry = Entry::findOne(['id' => $entryId, 'siteId' => $destinationSiteId, 'status' => null]);
//TODO Handle different section propagation methods ?
$newTitle = Deepl::getInstance()->api->translateString(
$sourceEntry->title,
$sourceSite->language,
$destinationSite->language
);
$newValues = Deepl::getInstance()->mapper->entryMapper($sourceEntry, $targetEntry);
// Save the translated version of the entry as a new draft
/** @var Element|DraftBehavior $element */
$draft = Craft::$app->getDrafts()->createDraft(
$targetEntry,
Craft::$app->getUser()->getIdentity()->id,
'Translation',
'Creating DeepL translation',
);
$draft->setCanonical($targetEntry);
$draft->setScenario(Element::SCENARIO_ESSENTIALS);
$draft->setFieldValues($newValues);
$draft->title = $newTitle;
$draft->slug = "";
// I'm assuming that is followed by
// Craft::$app->getElements()->saveElement($draft); |
@brandonkelly that solved the problem indeed, thanks! |
Glad to hear! |
Description
When working with multiple drafts for the same Entry, the Entry title is not merged back into the working draft after the Entry is updated. This only applies to the Entry title; updates to field values are merged back into the draft as described in #4642 (comment).
Steps to reproduce
Additional info
Resources
CleanShot.2021-10-14.at.11.08.21.mp4
References
The text was updated successfully, but these errors were encountered: