getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

[K4] Link Field - Link to page not working when UUIDs disabled #6075

Open doldenroller opened 11 months ago

doldenroller commented 11 months ago

Description

The Linkfield try to save the URL of a page when UUIDs are disabled. In a development enviroment the field connot be saved, because the local URL is considered not valid by the System.

Expected behavior

The Page ID should be saved.

Screenshots

Bildschirmfoto 2023-12-18 um 11 16 20 Bildschirmfoto 2023-12-18 um 11 16 47 Bildschirmfoto 2023-12-18 um 11 17 05

To reproduce

  1. Disable UUIDs in config.php
  2. Add Linkfield in Blueprint
  3. Try to Link to a Page

Your setup

Kirby Version

4.0.1

Your system (please complete the following information)

Additional context

afbora commented 10 months ago

I can't reproduce the issue, because this is not related with UUID. I don't think this is a bug. You entered https://dev-ssl:8890 and this is not valid URL as expected behavior. You can't save that url as custom type either.

doldenroller commented 10 months ago

The https://dev-ssl:8890is my testenviroment and I didn't type that in. It was changend to url as soon as I picked a page.

https://github.com/getkirby/kirby/assets/29595303/82789fb9-cd06-4702-aca7-94a273a18ea1

This doesn't happend when UUIDs are enabled.

afbora commented 10 months ago

Because stores as page://uuid instead absolute url when uuid enabled.

doldenroller commented 10 months ago

But storing the absolute URL when UUIDs are disabled doesn't really makes sense. If you want to deploy it to a liveserver or change the domainname of the site all links would be broken. It should be stored as relative path of the page.

Basicly it should do the same as the pages-field when UUIDs are disabled.

doldenroller commented 10 months ago

Funny thing is, that the type changes from Page to Url and creates the absolute path of the page that can't be saved. But when I delete the domain and just leave the relative path it can be saved. Even if the type is still Url. The small red cross indicates that it's not a valid url, but it still can be saved. I guess this is kind of a temporary workaround, but not the real solution.

https://github.com/getkirby/kirby/assets/29595303/1bb6cdec-99e4-4096-a67d-15e9719f6acb

lukasbestle commented 10 months ago

The behavior to store absolute URLs was introduced in https://github.com/getkirby/kirby/pull/5547. I agree it would be more robust to store paths instead, maybe with leading slash (like /path/to/page). With a <base> tag these URLs would then also work in subfolder setups.

medienbaecker commented 8 months ago

I just came across this bug in a project.

Because the link field is also used in Writer and Textarea fields, my editors were creating absolute links everywhere 🤦‍♂️ After moving to the live environment, I had to update all of the URLs to make them work.

Why disable UUIDs in the first place? It seemed to be a good workaround for the duplicate issue https://github.com/getkirby/kirby/issues/4867.

The UI for inserting links is simply not working as expected when UUIDs are disabled:

  1. Changing the environment/url breaks the links
  2. The page doesn't get resolved in previews (structure/object fields)
  3. No way to check if the link is a page link or external URL (it's always external)

UUIDs enabled:

CleanShot 2024-03-05 at 17 30 28

UUIDs disabled:

CleanShot 2024-03-05 at 17 30 03

Talking about the usage in Writer and Textarea fields: I'd expect a (link: ) tag with the slug just like the example in the docs.