Skip to content

Commit 6e14df6

Browse files
[5.x] Fix localized terms being returned incorrectly in the REST API (#11362)
1 parent 597d193 commit 6e14df6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Fieldtypes/Terms.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,15 @@ public function augment($values)
119119
{
120120
$single = $this->config('max_items') === 1;
121121

122-
if ($single && Blink::has($key = 'terms-augment-'.json_encode($values))) {
122+
// The parent is the item this terms fieldtype exists on. Most commonly an
123+
// entry, but could also be something else, like another taxonomy term.
124+
$parent = $this->field->parent();
125+
126+
$site = $parent && $parent instanceof Localization
127+
? $parent->locale()
128+
: Site::current()->handle(); // Use the "current" site so this will get localized appropriately on the front-end.
129+
130+
if ($single && Blink::has($key = 'terms-augment-'.$site.'-'.json_encode($values))) {
123131
return Blink::get($key);
124132
}
125133

0 commit comments

Comments
 (0)