Merge pull request #17118 from lcdservices/dev-core-1722
[civicrm-core.git] / Civi / API / SelectQuery.php
index d7c6d3f12733f18d2c0ec4b8823137896a8e2bfc..22577b92c3c0dd05a4a91b07a2626b8b5613a6c7 100644 (file)
@@ -85,7 +85,7 @@ abstract class SelectQuery {
     $baoName = _civicrm_api3_get_BAO($entity);
     $bao = new $baoName();
 
-    $this->entityFieldNames = _civicrm_api3_field_names(_civicrm_api3_build_fields_array($bao));
+    $this->entityFieldNames = array_column($baoName::fields(), 'name');
     $this->apiFieldSpec = $this->getFields();
 
     $this->query = \CRM_Utils_SQL_Select::from($bao->tableName() . ' ' . self::MAIN_TABLE_ALIAS);
@@ -210,7 +210,7 @@ abstract class SelectQuery {
       if (!isset($fkField['FKApiSpec'])) {
         $fkField['FKApiSpec'] = \_civicrm_api_get_fields($fkField['FKApiName']);
       }
-      $fieldInfo = \CRM_Utils_Array::value($fieldName, $fkField['FKApiSpec']);
+      $fieldInfo = $fkField['FKApiSpec'][$fieldName] ?? NULL;
 
       $keyColumn = \CRM_Utils_Array::value('FKKeyColumn', $fkField, 'id');
       if (!$fieldInfo || !isset($fkField['FKApiSpec'][$keyColumn])) {
@@ -259,7 +259,7 @@ abstract class SelectQuery {
   protected function getJoinInfo(&$fkField, $stack) {
     if ($fkField['name'] == 'entity_id') {
       $entityTableParam = substr(implode('.', $stack), 0, -2) . 'table';
-      $entityTable = \CRM_Utils_Array::value($entityTableParam, $this->where);
+      $entityTable = $this->where[$entityTableParam] ?? NULL;
       if ($entityTable && is_string($entityTable) && \CRM_Core_DAO_AllCoreTables::getClassForTable($entityTable)) {
         $fkField['FKClassName'] = \CRM_Core_DAO_AllCoreTables::getClassForTable($entityTable);
         $fkField['FKApiName'] = \CRM_Core_DAO_AllCoreTables::getBriefName($fkField['FKClassName']);
@@ -361,7 +361,7 @@ abstract class SelectQuery {
    * Get acl clause for an entity
    *
    * @param string $tableAlias
-   * @param string $baoName
+   * @param \CRM_Core_DAO|string $baoName
    * @param array $stack
    * @return array
    */