Skip to content
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

3.37.0 Incorrect doc localization reference #3990

Closed
stepanjakl opened this issue Jan 7, 2023 · 3 comments
Closed

3.37.0 Incorrect doc localization reference #3990

stepanjakl opened this issue Jan 7, 2023 · 3 comments
Assignees
Labels

Comments

@stepanjakl
Copy link
Contributor

Hello,

I am quite unsure what caused this issue, but suddenly in an A3 app, the current localization key stopped appearing. The localization object started pointing to the previous doc version. I don't really know why the previous doc versions of the home page were created in the first place.

Screenshot 2023-01-07 at 13 10 22

I dug deeper into the codebase and found that the localizations array consists of few different docs:

const localizations = await self.apos.doc.db.find({

Screenshot 2023-01-06 at 12 28 31

It just happens to pick the first object that satisfies this condition (which in our case is the previous doc version):

const doc = localizations.find(doc => doc.aposLocale.split(':')[0] === name);

I managed to fix it with a modified condition:

const doc = localizations.find(doc => doc.aposLocale.split(':')[0] === name && doc.aposLocale.split(':')[1] === context.aposLocale.split(':')[1]);

I can create a PR for this if you think it's a suitable solution.

However, my suggestion only treats the symptomps as the cause of the issue (i.e. the generated previous docs) might lay somewhere else.

@ValJed
Copy link
Contributor

ValJed commented Jan 10, 2023

Hi @stepanjakl !
Thank you for this detailed issue.
You're right this is a bug from apostrophe, but in the localization the previous docs should not be available.
The issue comes from the property aposMode that is not properly updated when switching a published doc into a previous one.

I'm currently working on a fix, I keep you informed.

@ValJed
Copy link
Contributor

ValJed commented Jan 11, 2023

A PR is open to fix this issue. It should be available in the next release.
You can use it or test it on this branch if needed.

@stepanjakl
Copy link
Contributor Author

Hello @ValJed, thank you for sorting this out so quickly! It is working well now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants