AcclaroInc / craft-translations

Easily manage your Craft CMS website translations and drive global growth with simplified translation workflows.
https://plugins.craftcms.com/translations
Other
9 stars 12 forks source link

Craft 5 Issue Applying Draft #518

Open LinneaHarts opened 2 months ago

LinneaHarts commented 2 months ago

When trying to Merge and Apply a Draft, I keep getting a "title" array key not found error. There is a Craft 5 release of this out, but the Craft 5 support ticket hasn't been closed yet, so I'm confused if this release is ready or not.

MerrittBoydston commented 2 months ago

🆕 Updates

LinneaHarts commented 2 months ago

I found this error was in the NeoFieldTranslator.php file, trying to send a title into the Neo blocks. Not sure why that was added in Crart 5, but removing it fixed this issue.

I've found a number of other issues with field handles though.

MerrittBoydston commented 2 months ago

Thank you for the quick follow-up.

We initially discovered this bug but were unsure if it was specific to neo field or more widespread. However, your confirmation has been helpful. The plan is to push a fix for this tomorrow.

Can you describe the issues you're experiencing with field handles?

LinneaHarts commented 2 months ago

Because Craft 5 created so many more field handles (and it seems like they are not always stored consistently) I was getting errors when I created new orders, saying, for instance "field handle cta3 not found". I added a try catch block in HyperLinkFieldTranslator and AssetFieldTranslator to handle the errors I saw, but there may be others. I haven't tested entries with every field type.

https://github.com/imarc/craft-translations/blob/f7db5162c1098d5637d59f2b3ffa0a3af2a47e60/src/services/fieldtranslator/HyperLinkFieldTranslator.php#L31 https://github.com/imarc/craft-translations/blob/a7407e219d734babdd623ef7a0d3a6f19591d2ae/src/services/fieldtranslator/AssetsFieldTranslator.php#L28

(I'm maintaining a separate fork that has a ChatGPT connector for a client -- who is paying for the license -- so I've been debugging myself.)

MerrittBoydston commented 2 months ago

Thank you for the detailed information. We'll continue working on this and communicate with you in this ticket.

MerrittBoydston commented 2 months ago

Hi @LinneaHarts, we have a new beta release v4.0.0-beta.2 that should fix your issue.

LinneaHarts commented 2 months ago

I can't test if this will work because it can't create an order without also giving an "Invalid field handle" error for any new fields that Craft 5 created.

LinneaHarts commented 2 months ago

Sorry, this was because I hadn't converted my SuperTable fields yet. I was able to successfully create an order. Now trying to process it!

LinneaHarts commented 2 months ago

No, this is still having the same problem with applying drafts. I'm getting invalid field handles and the only way to fix it is using craft's merge capabilities, but that causes other problems.

sidedwards commented 2 months ago

Hi @LinneaHarts, thank you for your patience as we refine the Craft 5 beta.

Could you share some specific steps to reproduce the issue you're experiencing? Screenshots or screen recordings are very helpful for our team to identify and resolve more quickly.

MerrittBoydston commented 2 months ago

Hello @LinneaHarts, I wanted to follow up here on @sidedwards request.

LinneaHarts commented 2 months ago

I'm afraid I'm not a great example because I do maintain a separate branch of the plugin to add a ChatGPT translator. I fixed my own issues on this particularly client site by using Craft's merge command on the fields it was complaining about, as well as adding this code to the field translators.

try {
            $blocks = $element->getFieldValue($field->handle);
            $fieldHandle = $field->handle;
        } catch (\Exception $e) {
            $blocks = $element->getFieldValue(preg_replace('/\d+$/', '', $field->handle));
            $fieldHandle = preg_replace('/\d+$/', '', $field->handle);
        }
MerrittBoydston commented 1 month ago

@LinneaHarts - it looks like this may has been resolved, do you mind testing this again on your end?

MerrittBoydston commented 3 weeks ago

Hi @LinneaHarts - just following up here again

LinneaHarts commented 3 weeks ago

I just got a chance to test this yesterday. I think it's working! Bearing in mind that I merged your update into my own fork. Thanks!

MerrittBoydston commented 3 weeks ago

I just got a chance to test this yesterday. I think it's working! Bearing in mind that I merged your update into my own fork. Thanks!

Great, thank you @LinneaHarts, feel free to open another ticket if you run into any other complications.

LinneaHarts commented 3 weeks ago

Actually, with further testing, there may be something going on. Stand by

LinneaHarts commented 3 weeks ago

No, the problem is persisting. It is having trouble with hyper fields at the moment, perhaps others.

MerrittBoydston commented 3 weeks ago

No, the problem is persisting. It is having trouble with hyper fields at the moment, perhaps others.

@LinneaHarts - we'll continue looking into this.

If we need any more information from you, like steps for repro, we'll touch base here.

LinneaHarts commented 3 weeks ago

I do have it more-or-less working on this fork/branch https://github.com/imarc/craft-translations/tree/chatgpt-craft5

LinneaHarts commented 2 weeks ago

When I did a merge on the offending field using the fields/merge command, I was able to merge, but now it's creating a new revision that removes all the content in the source language.

LinneaHarts commented 2 weeks ago

I was able to fix this by adding the following code from line 100-112 https://github.com/imarc/craft-translations/blob/chatgpt-craft5/src/services/repository/EntryRepository.php#L100

sidedwards commented 2 weeks ago

@LinneaHarts thank you for the update. We will investigate this further and review your proposed solution. Thanks for your patience on this issue 🙏

sidedwards commented 1 week ago

@LinneaHarts, would you mind testing this again with the latest version to see if that resolves your issue? The code you mentioned above is included here:

https://github.com/AcclaroInc/craft-translations/blob/a26aa6e6c1e087c2f30b7c266e9a3f5a2a4f05ab/src/services/repository/EntryRepository.php#L106C13-L118C27

MerrittBoydston commented 4 days ago

Hi @LinneaHarts, just following up here on @sidedwards' comment. Let me know if this resolves your issue