pcp.user.actions - Decompose deviant list of links
authorTim Otten <totten@civicrm.org>
Tue, 19 Sep 2023 05:06:54 +0000 (22:06 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 3 Oct 2023 04:44:59 +0000 (21:44 -0700)
The problem is that:

* `hook_links('pcp.user.actions')` fires with a malformed set links
* The malformed set of links has been specifically encoded into unit tests

So fixing the bad links would likely break some consumer. (I don't see the
consumer in my copy of `universe`, but if someone wrote the test, then they
must've really meant it...)

This patch adds alternative variants (`hook_links('pcp.user.actions.add')` and
`hook_links('pcp.user.actions.all')`) which should replace it.

CRM/PCP/BAO/PCP.php

index 3f78c95392422c5259126f490252cc7d2b94fc46..5c504f844184555f56dd9e36330cc96cc99adbed 100644 (file)
@@ -344,7 +344,11 @@ WHERE pcp.id = %1 AND cc.contribution_status_id = %2 AND cc.is_test = 0";
         ],
       ];
 
+      // pcp.user.actions emits a malformed set of $links. But it is locked-in via unit-test, so we'll grandfather
+      // the bad one and fire new variants that are well-formed.
       CRM_Utils_Hook::links('pcp.user.actions', 'Pcp', $pcpId, self::$_pcpLinks);
+      CRM_Utils_Hook::links('pcp.user.actions.add', 'Pcp', $pcpId, self::$_pcpLinks['add']);
+      CRM_Utils_Hook::links('pcp.user.actions.all', 'Pcp', $pcpId, self::$_pcpLinks['all']);
     }
     return self::$_pcpLinks;
   }