Open motion-work opened 9 months ago
any updates on this? 😬
No updates yet sorry. You'd see them here if there were.
alrighty thanks for the reply
I'm not able to fix it right now, but this is a note for us or whoever wants to tackle this:
The issue is here: https://github.com/statamic/cms/blob/1f08790aa9b53325c1f4a4bd4ee91507b95362ad/src/Fieldtypes/Bard/LinkMark.php#L69
It's localizing to the current site, which works great on the frontend but not in the APIs. Instead of Site::current()
, it should somehow get the site of the parent entry (the one where the bard field is). Accessing that from within the LinkMark
class might be challenging.
In my project I "fixed" this by injecting a middleware into the Statamic GraphQL queries
class ResolveSite extends Middleware
{
public function handle($root, array $args, $context, ResolveInfo $info, Closure $next)
{
$site = $args['site'] ?? Site::default()->handle();
Site::setCurrent($site);
return $next($root, $args, $context, $info);
}
}
This solution isn't that nice because of it being a side-effect in a query, however it does work quite well even with fetching multiple sites, and doesn't require refactoring all the Site::current()
occurrences.
Currently facing same issue with REST API 😞
Bug description
I have a Statamic instance configured with multisite (German, French, and Italian). The default root locale is set to German. Also I am fetching the CMS data via the GraphQL endpoint. the same bug applies for the REST api as well.
Within a bard field, when I link to an entry of the same locale - for example, French entry to another French entry, I expect the linked entry to resolve to the French URL
/fr/first-page
->/fr/second-page
, but it currently does not.How to reproduce
Current behavior
French linked entry within Bard field resolves to German url of the linked entry. for example:
/fr/french-page-a
->/de/german-page-a
it resolves to the correct entry but in the wrong locale
Expected behavior
/fr/french-page-a
->/fr/french-page-a
Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
None
Additional details
I have found this merged issue which seems to fix this similar bug but not for the GraphQL and REST api: https://github.com/statamic/cms/pull/8319