FIX Allow subclasses of ManyMany lists in EagerLoadedList (#10905)

This commit is contained in:
Guy Sartorelli 2023-08-08 14:43:08 +12:00 committed by GitHub
parent c9f48089c9
commit f345646481
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -889,7 +889,7 @@ class EagerLoadedList extends ViewableData implements Relation, SS_List, Filtera
*/
public function getExtraData($componentName, int|string $itemID): array
{
if (!in_array(get_class($this->dataList), [ManyManyList::class, ManyManyThroughList::class])) {
if (!($this->dataList instanceof ManyManyList) && !($this->dataList instanceof ManyManyThroughList)) {
throw new BadMethodCallException('Cannot have extra fields on this list type');
}
@ -926,7 +926,7 @@ class EagerLoadedList extends ViewableData implements Relation, SS_List, Filtera
*/
public function getExtraFields(): array
{
if (!in_array(get_class($this->dataList), [ManyManyList::class, ManyManyThroughList::class])) {
if (!($this->dataList instanceof ManyManyList) && !($this->dataList instanceof ManyManyThroughList)) {
throw new BadMethodCallException('Cannot have extra fields on this list type');
}
return $this->extraFields;