pluginpal / strapi-webtools

🔗 Unique, flexible and autogenerated URLs for your Strapi managed web content.
https://www.pluginpal.io/plugin/webtools
MIT License
34 stars 14 forks source link

url_alias localizations not saving relation #185

Open aaronLejeune opened 2 months ago

aaronLejeune commented 2 months ago

Bug report

Hi there! Thanks a lot for this great plugin! Since we've been scaling our app a bit, we're experiencing some strange reactions when generating localised links in collection types.

Context

When we create a new page in a collection type eg.: support, our urls gets generated nicely: sceenshot admin panel: image screenshot database:

image

Bug

Problem is, the localised versions are not linked for some reason. We get the data back like this: (using graphQL)

"url_alias": {
    "data": {
        "id": "508",
        "attributes": {
            "url_path": "/en/support/video-guides/",
            "locale": "en",
            "localizations": {
                "data": []
            }
        }
    }
}

when taking a look in the wt_url_alias_localizations_links table in our database, we can see that the ID references are not present. Sometimes, the relation is saved when we change slugs, delete an item , .... but then often, just one reference will be present.

image

We tried to "Bulk generate" the collections but while we received a Success: Successfully generated 4 URL aliases. - there were still no localizations present. This affected both local and production machines while the data is the same.

System

boazpoolman commented 2 months ago

I have confirmed this issue when creating/updating pages in the content manager. The localizations were not properly saved, I've fixed this in PR https://github.com/pluginpal/strapi-webtools/pull/187.

Though @aaronLejeune, as you mention, you also don't have the correct localizations after bulk generating the URL aliases. I can't seem to reproduce that side of the issue. Whenever I bulk generate, all the localizations end up in the right place.

Is there anything I'm missing?

aaronLejeune commented 2 months ago

@boazpoolman thank you for looking into it!

Indeed the correct localizations after bulk generation are no there as well. When generating, all urls are made correct, meaning they are all parsed as they should eg.: image

Its just that they seem to disconnect the localised version for some reason. I need to mention that I am doing a "hacky" way of generating URL's. Eg.:

I have a single type shop overview page and a collection type shop pages where I have the following URL patterns: image image

the collection type shop pages have a one-way relation to shop overview page - which is exctually not supported by Strapi, but I am doing nevertheless. I do that so I can get the slug of the parent page. Maybe that can be the reason why these localisations are sometimes not saving.

I got a workaround by fetching localisations from the page itself, instead of going inside the url_alias object so Im good for now :)

boazpoolman commented 2 months ago

Thanks for clarifying @aaronLejeune.

I can't imagine your single type relation would have any effect on the translations. Is there any way you could provide some steps on how to reproduce this issue from a fresh Strapi install?

I would love to get this issue resolved!

boazpoolman commented 2 months ago

I've released the fix I was talking about in v1.0.0-beta.14. You could try that out to see if the issues are resolved.