wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
226 stars 87 forks source link

Page tree problems after translating including subtree #773

Open leewesleyv opened 9 months ago

leewesleyv commented 9 months ago

When translating a page through the Wagtail admin (localize/submit/page/) and including the subtree, the (translated) page tree is corrupt. The numchild value for the translated page stays 0, which causes the subpages to not appear in the Wagtail admin. I've been able to reproduce this on multiple Wagtail instances.

Screenshot 2024-02-02 at 09 18 57 Screenshot 2024-02-02 at 09 23 02 Screenshot 2024-02-02 at 09 23 20

Screenshot 2024-02-02 at 09 30 18

How to reproduce

On a fresh installation of Wagtail (using wagtail start), configure i18n using the Wagtail docs. Install wagtail-localize following the installation guide. Then perform the following actions:

zerolab commented 9 months ago

Hey @leewesleyv, Thank you for reporting this. Which versions of wagtail-localize/Wagtail are you on?

leewesleyv commented 9 months ago

@zerolab

Currently using the following versions:

wagtail==5.2.3
wagtail-localize==1.7

Besides these versions I've tried with main (of wagtail-localize) where the problem also seems to be present.

danthedeckie commented 9 months ago

Does running the ./manage.py fixtree help?

leewesleyv commented 9 months ago

@danthedeckie Running that command will indeed find and fix the problem (see 4th screenshot in https://github.com/wagtail/wagtail-localize/issues/773#issue-2114412105).

zerolab commented 9 months ago

By way of update: I was hoping to get to it last week, but I didn't get to it, sorry!

zerolab commented 5 months ago

I was able to replicate this. Working on a fix

stevejalim commented 1 month ago

Naively wondering if we can effectively run fixtree after the page copying process has run. Will see if I can make time to address it this way, as this is a blocker for us and I'm happy to help

stevejalim commented 1 month ago

Rummaging around, trying to pinpoint where the page tree goes awry.

I slotted in a call to wagtail.management.commands.fixtree.Command().handle() just a the end of form_valid to see if that would spot any issues with the tree just after the translations were made.

It appears not:

> /Users/steve/Code/wagtail-localize/wagtail_localize/views/submit_translations.py(164)form_valid()
-> ft_func()
(Pdb) ft_func()
Checking page tree for problems...
No problems found.

Checking page tree for problems...
No problems found.

Checking collection tree for problems...
No problems found.

INFO 2024-10-14 07:47:57,950 signal_handlers Creating redirects for page: 'REDACTED base route' id=45
INFO 2024-10-14 07:47:57,978 signal_handlers 0/0 redirects were created successfully.
INFO 2024-10-14 07:47:57,991 publish_revision Published: "REDACTED base route" pk=45 revision_id=156
INFO 2024-10-14 07:47:58,003 publish_revision Published: "Hello, World" pk=50 revision_id=158
INFO 2024-10-14 07:47:58,067 publish_revision Published: "test parent page" pk=51 revision_id=160
INFO 2024-10-14 07:47:58,082 publish_revision Published: "child of parent page" pk=52 revision_id=162

So now it's off to deeper in the stack, possibly in core wagtail(?)

If anyone else knows where this is being caused, please do say 😄

zerolab commented 1 month ago

Thank you for the investigation @stevejalim Added to my list for this week.