projects
/
civicrm-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixes dev/core#2984 - Give clear error message when entity's component is disabled
[civicrm-core.git]
/
Civi
/
API
/
SelectQuery.php
diff --git
a/Civi/API/SelectQuery.php
b/Civi/API/SelectQuery.php
index 92e09ad8d1c977ecf446e7988ac464c6da6ded3b..76ae48e06489fc2d230ca3d487d82a11d2229952 100644
(file)
--- a/
Civi/API/SelectQuery.php
+++ b/
Civi/API/SelectQuery.php
@@
-11,6
+11,7
@@
namespace Civi\API;
use Civi\API\Exception\UnauthorizedException;
namespace Civi\API;
use Civi\API\Exception\UnauthorizedException;
+use CRM_Core_Exception;
/**
* Query builder for civicrm_api_basic_get.
/**
* Query builder for civicrm_api_basic_get.
@@
-63,7
+64,7
@@
abstract class SelectQuery {
/**
* @var array
*/
/**
* @var array
*/
- protected $entityFieldNames;
+ protected $entityFieldNames
= []
;
/**
* @var array
*/
/**
* @var array
*/
@@
-78,11
+79,16
@@
abstract class SelectQuery {
/**
* @param string $entity
* @param bool $checkPermissions
/**
* @param string $entity
* @param bool $checkPermissions
+ *
+ * @throws \CRM_Core_Exception
*/
public function __construct($entity, $checkPermissions) {
$this->entity = $entity;
require_once 'api/v3/utils.php';
$baoName = _civicrm_api3_get_BAO($entity);
*/
public function __construct($entity, $checkPermissions) {
$this->entity = $entity;
require_once 'api/v3/utils.php';
$baoName = _civicrm_api3_get_BAO($entity);
+ if (!$baoName) {
+ throw new CRM_Core_Exception('Invalid entity: ' . \CRM_Utils_Type::validate($entity, 'Alphanumeric'));
+ }
$bao = new $baoName();
$this->entityFieldNames = array_column($baoName::fields(), 'name');
$bao = new $baoName();
$this->entityFieldNames = array_column($baoName::fields(), 'name');
@@
-239,7
+245,7
@@
abstract class SelectQuery {
$this->join($side, $fkTable, $tableAlias, $joinCondition);
if (strpos($fieldName, 'custom_') === 0) {
$this->join($side, $fkTable, $tableAlias, $joinCondition);
if (strpos($fieldName, 'custom_') === 0) {
-
list($tableAlias, $fieldName)
= $this->addCustomField($fieldInfo, $side, $tableAlias);
+
[$tableAlias, $fieldName]
= $this->addCustomField($fieldInfo, $side, $tableAlias);
}
// Get ready to recurse to the next level
}
// Get ready to recurse to the next level
@@
-361,11
+367,11
@@
abstract class SelectQuery {
* Get acl clause for an entity
*
* @param string $tableAlias
* Get acl clause for an entity
*
* @param string $tableAlias
- * @param string $baoName
+ * @param
\CRM_Core_DAO|
string $baoName
* @param array $stack
* @return array
*/
* @param array $stack
* @return array
*/
- p
rotected
function getAclClause($tableAlias, $baoName, $stack = []) {
+ p
ublic
function getAclClause($tableAlias, $baoName, $stack = []) {
if (!$this->checkPermissions) {
return [];
}
if (!$this->checkPermissions) {
return [];
}
@@
-473,7
+479,7
@@
abstract class SelectQuery {
}
}
elseif ($field && strpos($fieldName, 'custom_') === 0) {
}
}
elseif ($field && strpos($fieldName, 'custom_') === 0) {
-
list($table_name, $column_name)
= $this->addCustomField($field, 'LEFT');
+
[$table_name, $column_name]
= $this->addCustomField($field, 'LEFT');
if ($field['data_type'] != 'ContactReference') {
// 'ordinary' custom field. We will select the value as custom_XX.
if ($field['data_type'] != 'ContactReference') {
// 'ordinary' custom field. We will select the value as custom_XX.