-
- if ($this->_component == 'event') {
- $ids['event'] = self::getValue('e', TRUE);
- $ids['participant'] = self::getValue('p', TRUE);
- $ids['contributionRecur'] = $this->getContributionRecurID();
- }
- else {
- // get the optional ids
- //@ how can this not be broken retrieving from GET as we are dealing with a POST request?
- // copy & paste? Note the retrieve function now uses data from _REQUEST so this will be included
- $ids['membership'] = self::retrieve('membershipID', 'Integer', 'GET', FALSE);
- $ids['contributionRecur'] = $this->getContributionRecurID();
- $ids['contributionPage'] = self::getValue('p', FALSE);
- $ids['related_contact'] = self::retrieve('relatedContactID', 'Integer', 'GET', FALSE);
- $ids['onbehalf_dupe_alert'] = self::retrieve('onBehalfDupeAlert', 'Integer', 'GET', FALSE);
- }
-
- if (!$ids['membership'] && $this->getContributionRecurID()) {
- $sql = "
- SELECT m.id
- FROM civicrm_membership m
-INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contribution_id = %1
- WHERE m.contribution_recur_id = %2
- LIMIT 1";
- $sqlParams = [
- 1 => [$ids['contribution'], 'Integer'],
- 2 => [$this->getContributionRecurID(), 'Integer'],
- ];
- if ($membershipId = CRM_Core_DAO::singleValueQuery($sql, $sqlParams)) {
- $ids['membership'] = $membershipId;
- }
- }
-
- $paymentProcessorID = $this->_inputParameters['processor_id'] ?? $this->getPayPalPaymentProcessorID();
-
- $contribution = $this->getContributionObject();
-
- // CRM-19478: handle oddity when p=null is set in place of contribution page ID,
- if (!empty($ids['contributionPage']) && !is_numeric($ids['contributionPage'])) {
- // We don't need to worry if about removing contribution page id as it will be set later in
- // CRM_Contribute_BAO_Contribution::loadRelatedObjects(..) using $objects['contribution']->contribution_page_id
- unset($ids['contributionPage']);
- }
-
- $ids['paymentProcessor'] = $paymentProcessorID;
- $contribution->loadRelatedObjects($input, $ids);
-
- $input['payment_processor_id'] = $paymentProcessorID;