Skip to content

bugfixes for membership actions

sebalis requested to merge sebalis/civirules:membership-action-fixes into master

I found two mistakes when looking at the Civirules action Add Membership and would like to submit fixes.

First, in the form to edit an Add Membership action, where a membership type is to be supplied, option values are wrong. This is due to array_merge being used in CRM_CivirulesActions_Membership_Form_Add, this tunction does not preserve numerical index values. Example #2 in the PHP documentation suggests the + operator to be used if numerical index values in arrays to be merged must be preserved. This is a safe operation here as the first array to be merged has one non-numerical index and the second array has numerical IDs from the database as index values. This error can be seen when a Add Membership action is created or edited. The very first membership type, whose id is 1 but creates an option value of 0, actually creates a PHP error when used. Inspecting the select element in the action form shows the overall problem.

Second, in CRM_Civirules_Utils the getMembershipTypes method uses the “where” condition is_active = true irrespective of the value of the $onlyActive parameter, and then adds the same condition again if $onlyActive is true, so I deleted the line that sets that condition irrespectively.

Edited by sebalis

Merge request reports

Loading