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

Improve link kirbytag behavior when uuid point to non-existing page #6085

Merged
merged 4 commits into from
Jan 15, 2024

Conversation

afbora
Copy link
Member

@afbora afbora commented Dec 22, 2023

This PR …

Fixes

Breaking changes

None

Ready?

  • Unit tests for fixed bug/feature
  • In-code documentation (wherever needed)
  • Tests and checks all pass

For review team

@afbora afbora added the type: bug 🐛 Is a bug; fixes a bug label Dec 22, 2023
@afbora afbora added this to the 4.0.3 milestone Dec 22, 2023
@afbora afbora requested a review from a team December 22, 2023 09:54
@afbora afbora self-assigned this Dec 22, 2023
Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'm not sure about this. It could be pretty unexpected to get a link to the homepage instead of the intended deeplink.

An alternative could be to return an empty string instead (meaning the KirbyTag would produce an empty output, i.e. no link at all).

However both solutions have in common that they are very hard to debug. The exception on the other hand breaks the whole page. Difficult...

@afbora
Copy link
Member Author

afbora commented Dec 22, 2023

What about link to error page instead homepage?

@lukasbestle
Copy link
Member

I like that. Then it's just a "broken link" as it would be with a hardcoded URL or path.

@distantnative
Copy link
Member

I think other CMS in similar cases would output the text without any link in this case.

@afbora
Copy link
Member Author

afbora commented Dec 22, 2023

Good comments. I would merge ideas :)

  • Link to the error page or throw exception if debug enabled
  • Remove link from text if debug disabled

@afbora
Copy link
Member Author

afbora commented Dec 24, 2023

when text attr set

Will removed link. I got this case, OK.

Input

Lorem ipsum (link: page://not-exist text: Click Here) dolor sit amet

Output

Lorem ipsum Click Here dolor sit amet

when no text attr set

What would expected when no link text set?

Input

Lorem ipsum (link: page://not-exist) dolor sit amet

Output

Remove whole kirbytag like that?

Lorem ipsum dolor sit amet

@afbora afbora closed this Dec 24, 2023
@afbora afbora reopened this Dec 24, 2023
@distantnative
Copy link
Member

Given the amount of discussion about this, I think this should not go into a patch release.

On the discussion points

  • What happens with a permalink when the UUID does not exist? Is it an exception or redirect to error? I would say the kirbytag should behave the same when debug is active
  • With debug false, I think just rendering the text, not the link is ok.
  • When no text is set, url should be rendered as pure text.

@afbora
Copy link
Member Author

afbora commented Dec 28, 2023

When no text is set, url should be rendered as pure text.

@distantnative So what would happen when no text is set, uuid is not exists and debug active?

@distantnative
Copy link
Member

@afbora depends what our answer is to my first bullet point. Either exception or permalink as pure text.

@GiantCrocodile
Copy link

Another thing to consider: The expected behavior might depend on the importancy of the link. If it's a link to a legal document or important document, it should always fail to prevent failing legal or other processes afterwards. So maybe it might be important to have a way that the editor/admin can define the expected behavior by the importancy of the link.

@distantnative distantnative marked this pull request as draft December 30, 2023 11:47
@lukasbestle
Copy link
Member

Considering everything, I think the following would be the best compromise to fulfill the most requirements:

  • If debug mode is enabled, throw an exception to allow to pinpoint the source of the error. IMO that's what debug mode is for.
  • Otherwise, render a link to the error page. It keeps the intended content structure, avoids printing the UUID to visitors who won't know what it means and also makes it visible to visitors that there should be a link but it isn't working (thus prompting them to contact the editors to correct the issue on the page).

@afbora afbora changed the title Don't throw exception when uuid point to non-existing page Improve link kirbytag behavior when uuid point to non-existing page Jan 2, 2024
@afbora afbora marked this pull request as ready for review January 2, 2024 11:26
@afbora afbora requested review from lukasbestle and a team January 2, 2024 11:26
config/tags.php Outdated Show resolved Hide resolved
Copy link
Member

@bastianallgeier bastianallgeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change the wording for the exception (see suggestion). But I'm happy with the rest. @lukasbestle @distantnative do you want to have a last look at it? I would also move it to 4.1 though.

config/tags.php Outdated Show resolved Hide resolved
@afbora afbora force-pushed the fix/6083-link-kirbytag branch from 03be498 to 304e9a7 Compare January 9, 2024 09:47
@afbora afbora modified the milestones: 4.0.3, 4.0.4 Jan 10, 2024
config/tags.php Outdated Show resolved Hide resolved
Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! 👍
I agree with Bastian on the suggested change, apart from that it's great.

@afbora afbora force-pushed the fix/6083-link-kirbytag branch from 1513ae2 to 5766af2 Compare January 15, 2024 09:51
config/tags.php Outdated Show resolved Hide resolved
Co-Authored-By: Bastian Allgeier <[email protected]>
@bastianallgeier bastianallgeier merged commit e21e3ce into develop-patch Jan 15, 2024
10 checks passed
@bastianallgeier bastianallgeier deleted the fix/6083-link-kirbytag branch January 15, 2024 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Is a bug; fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kirbytext() fails, if text contains a link to a non-existing page
5 participants