diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 9d5e64a38a51..56acef4c3670 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -6419,6 +6419,10 @@ protected function prepareOrderBy($sort, $sortOrder) { if (!empty($pseudoConstantMetadata['optionGroupName']) || $this->isPseudoFieldAnFK($fieldSpec) ) { + // dev/core#1305 @todo this is not the right thing to do but for now avoid fatal error + if (empty($fieldSpec['bao'])) { + continue; + } $sortedOptions = $fieldSpec['bao']::buildOptions($fieldSpec['name'], NULL, [ 'orderColumn' => CRM_Utils_Array::value('labelColumn', $pseudoConstantMetadata, 'label'), ]);