X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FGeneric.php;h=9a55547607365e1828914cfcd6a0fe62c38c9528;hb=cd72683b6747c099858ca1b72fb2ae859dfcbe45;hp=0eef89a7a2f6114876af58579cf4df0607e48c75;hpb=9c204b425c4f161f3dec52e3d7f0cae2f9f35eb5;p=civicrm-core.git diff --git a/api/v3/Generic.php b/api/v3/Generic.php index 0eef89a7a2..9a55547607 100644 --- a/api/v3/Generic.php +++ b/api/v3/Generic.php @@ -419,8 +419,23 @@ function civicrm_api3_generic_getoptions($apiRequest) { CRM_Core_DAO::buildOptionsContext($context); unset($apiRequest['params']['context'], $apiRequest['params']['field'], $apiRequest['params']['condition']); - $baoName = _civicrm_api3_get_BAO($apiRequest['entity']); - $options = $baoName::buildOptions($fieldName, $context, $apiRequest['params']); + // Legacy support for campaign_id fields which used to have a pseudoconstant + if ($fieldName === 'campaign_id') { + $campaignParams = [ + 'select' => ['id', 'name', 'title'], + 'options' => ['limit' => 0], + ]; + if ($context === 'match' || $context === 'create') { + $campaignParams['is_active'] = 1; + } + $labelField = $context === 'validate' ? 'name' : 'title'; + $keyField = $context === 'match' ? 'name' : 'id'; + $options = array_column(civicrm_api3('Campaign', 'get', $campaignParams)['values'], $labelField, $keyField); + } + else { + $baoName = _civicrm_api3_get_BAO($apiRequest['entity']); + $options = $baoName::buildOptions($fieldName, $context, $apiRequest['params']); + } if ($options === FALSE) { return civicrm_api3_create_error("The field '{$fieldName}' has no associated option list."); } @@ -496,7 +511,12 @@ function _civicrm_api3_generic_get_metadata_options(&$metadata, $apiRequest, $fi return; } - $fieldsToResolve = $apiRequest['params']['options']['get_options']; + if (!is_array($apiRequest['params']['options'])) { + $fieldsToResolve = []; + } + else { + $fieldsToResolve = $apiRequest['params']['options']['get_options']; + } if (!empty($metadata[$fieldname]['options']) || (!in_array($fieldname, $fieldsToResolve) && !in_array('all', $fieldsToResolve))) { return;