Skip to content

Commit

Permalink
Fix localized terms being returned incorrectly in the REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Jan 16, 2025
1 parent 5fa2e18 commit fb24a43
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Fieldtypes/Terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,15 @@ public function augment($values)
{
$single = $this->config('max_items') === 1;

if ($single && Blink::has($key = 'terms-augment-'.json_encode($values))) {
// The parent is the item this terms fieldtype exists on. Most commonly an
// entry, but could also be something else, like another taxonomy term.
$parent = $this->field->parent();

$site = $parent && $parent instanceof Localization
? $parent->locale()
: Site::current()->handle(); // Use the "current" site so this will get localized appropriately on the front-end.

if ($single && Blink::has($key = 'terms-augment-'.$site.'-'.json_encode($values))) {
return Blink::get($key);
}

Expand Down

0 comments on commit fb24a43

Please sign in to comment.