Skip to content

Commit

Permalink
Improve usage within non-entries ...
Browse files Browse the repository at this point in the history
The collection should only be set when the parent is an entry.
The locale should only be retrieved if it's a Localizable object, like an Entry or a Term. Not a User.

Closes #2863
Fixes #2826

Co-authored-by: Arthur Perton <arthur@webenapp.nl>
  • Loading branch information
jasonvarga and arthurperton committed Nov 24, 2020
1 parent 2e4741c commit 6e04a08
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Fieldtypes/Terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Statamic\Fieldtypes;

use Statamic\Contracts\Data\Localization;
use Statamic\Contracts\Entries\Entry;
use Statamic\CP\Column;
use Statamic\Exceptions\TermsFieldtypeBothOptionsUsedException;
use Statamic\Exceptions\TermsFieldtypeTaxonomyOptionUsed;
Expand Down Expand Up @@ -86,11 +88,11 @@ private function getTermsForAugmentation($value)
// entry, but could also be something else, like another taxonomy term.
$parent = $this->field->parent();

if ($parent && $this->field->handle() === $taxonomy->handle()) {
if ($parent && $parent instanceof Entry && $this->field->handle() === $taxonomy->handle()) {
$term->collection($parent->collection());
}

$locale = $parent
$locale = $parent && $parent instanceof Localization
? $parent->locale()
: Site::current()->handle();

Expand Down

1 comment on commit 6e04a08

@jasonvarga
Copy link
Member Author

Choose a reason for hiding this comment

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

Should have been "fixes #2853", not 2863.

Please sign in to comment.