Use Permission=FALSE when retrieving price sets in examples
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 1 Jun 2023 21:55:45 +0000 (09:55 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 2 Jun 2023 03:27:29 +0000 (15:27 +1200)
Doing a check causes the whole example to fail -
and this feels like fairly public info

CRM/Contribute/WorkflowMessage/Contribution/BasicContribution.php
CRM/Event/WorkflowMessage/EventExamples.php
CRM/Member/WorkflowMessage/Membership/Membership.php

index 98f1f3e43c3d5c7951952b3b0adbcd1e74b37470..d3477bb3da10e1b50c3ab6be469098a53036606d 100644 (file)
@@ -134,7 +134,7 @@ class CRM_Contribute_WorkflowMessage_Contribution_BasicContribution extends Work
         $mockOrder->setDefaultFinancialTypeID($priceSet['financial_type_id']);
       }
     }
-    foreach (PriceField::get()->addWhere('price_set_id', '=', $mockOrder->getPriceSetID())->execute() as $index => $priceField) {
+    foreach (PriceField::get(FALSE)->addWhere('price_set_id', '=', $mockOrder->getPriceSetID())->execute() as $index => $priceField) {
       $priceFieldValue = PriceFieldValue::get()->addWhere('price_field_id', '=', $priceField['id'])->execute()->first();
       if (empty($example['is_show_line_items'])) {
         $priceFieldValue['amount'] = $contribution['total_amount'];
@@ -157,8 +157,7 @@ class CRM_Contribute_WorkflowMessage_Contribution_BasicContribution extends Work
    * @throws \CRM_Core_Exception
    */
   private function getNonQuickConfigPriceSet(): ?array {
-    // Permission check defaults to true - likely implicitly OK but may need to be false.
-    return PriceSet::get()
+    return PriceSet::get(FALSE)
       ->addWhere('is_quick_config', '=', FALSE)
       ->execute()
       ->first();
index 76dde4684f96852589f412cf3c4607456a1e33a2..556bb42b26fcffd39cf17fa2e2f8cb2223905544 100644 (file)
@@ -72,7 +72,6 @@ class CRM_Event_WorkflowMessage_EventExamples extends WorkflowMessageExample {
    * @throws \CRM_Core_Exception
    */
   private function getPriceSets(): ?array {
-    // Permission check defaults to true - likely implicitly OK but may need to be false.
     $quickConfigPriceSet = $this->getPriceSet(TRUE);
     $nonQuickConfigPriceSet = $this->getPriceSet(FALSE);
 
index 25c46a69509c6408765eeb778c5da04dcde31e5f..03d134e2896efe242a30ce1f1259dd58a585164d 100644 (file)
@@ -145,8 +145,7 @@ class CRM_Member_WorkflowMessage_Membership_Membership extends WorkflowMessageEx
    * @throws \CRM_Core_Exception
    */
   private function getPriceSet(): ?array {
-    // Permission check defaults to true - likely implicitly OK but may need to be false.
-    return (array) PriceSet::get()
+    return (array) PriceSet::get(FALSE)
       ->addWhere('extends', '=', CRM_Core_Component::getComponentID('CiviMember'))
       ->addOrderBy('is_quick_config', 'DESC')
       ->execute()->indexBy('id');