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

[5.x] Fix wrong url on the link mark node in bard fieldtype #11207

Merged
merged 4 commits into from
Dec 4, 2024

Conversation

christophstockinger
Copy link
Contributor

Goes along with #11206

Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

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

Thank you but that code is there for a reason. See the PR where it was added for context. #8319

I think that maybe we could just avoid localizing if we're in an API.

-if ($item instanceof Entry) {

+$isApi = Str::startsWith(request()->path(), [config('statamic.api.route'), 'graphql']);
+
+if (!$isApi && $item instanceof Entry) {

(I haven't tested that code - I just wrote it straight into the comment)

@christophstockinger
Copy link
Contributor Author

@jasonvarga I updated the PR.

I add two checks: One for the Rest-API and another for Graphql.

I tested the changes in our project with the bug and it works fine.

@christophstockinger
Copy link
Contributor Author

Just a note:

However, the more I think about it, the more I see this as a temporary fix.

I have already noticed in other places that the site handling does not always work correctly and Site::current() returns the default site in many cases, even though you are on a different site in the context.

I honestly think that this is a global problem in the CMS. Because changing a page in the control panel is often solved differently.
For example, if I change the site in the top bar, the site in the session is changed as far as I can understand.
If I am in an entry, I change the site via the ID in the URL.
If I am in the overview, I can change it via a filter, although I am still in the other page globally in the top bar.

Personally, I find this rather confusing and would like a more centralized handling here, then I also think the original code would not be possible without the fix from me.

I'm happy to contribute on how to optimize this, but I don't think I'd be the person to implement it as I'm not too deep in the code.

A first central solution would be, for example, a middleware that takes care of the site handling and injects the requests (whether API or views).

@jasonvarga
Copy link
Member

Yeah we know the top bar is confusing. statamic/ideas#350

@jasonvarga jasonvarga dismissed their stale review December 3, 2024 16:55

Change was made.

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

Successfully merging this pull request may close these issues.

2 participants