2

Hoping the CiviCRM expertise here within stackexchange can provide some guidance on a warning I'm seeing...

When an Anonymous individual on our WordPress CiviCRM site has a Group (Mailing List) selected in a Profile they are shown the following Warning message. Each Warning message is shown twice for each Group selected by the user.

Warning: in_array() expects parameter 2 to be array, null given in /home/coloradomaker/www/www/wp-content/plugins/civicrm/civicrm/CRM/ACL/API.php on line 218

Line 218 is the return statement for the groupPermission function.

A full image of the page after submitting my two Group (Mailing List) choices is shown below:

Image of Warning message

More background:

  1. There are two types of pages as the first submenu item under our Get Involved that are setup for an individual to provide their information for subscription to mailing lists: Logged in and not logged in. This warning happens if they are not logged in (Anonymous user). Does not happen if you are an Administrator (both as a WordPress user or in the CiviCRM Administrator group) or as a logged in user (Authenticated)
  2. Some of the Groups were originally created as both a Mailing List AND an Access Control List but I removed the designation that they were an ACL group when I saw this warning since we weren't ready to go full into our implementation of the frontend site. Changing the Groups back to a Mailing List only still did not get rid of the Warning.
  3. At one point I installed the BuddyPress Group sync but I Deactivated the plugin since I didn't want to use it yet.
  4. PHP 5.6, WordPress 4.9.2, CiviCRM 4.7, BuddyPress 2.9.3, BP XProfile WordPress User Sync 0.6.4, BP Groups CiviCRM Sync 0.3.5 (Deactivated)

Thoughts on how to remove the warning or complete the ACL such that there are no warnings?

  • What permissions do your users have for accessing groups? Admins have all permissions of course, so the issue won't be encountered. FWIW, I think it unlikely that the deactivated BP Groups CiviCRM Sync plugin is the cause since it doesn't touch permissions. – Christian Wach Feb 5 '18 at 17:55
  • Thank you for your time, Christian. When I tested it a day or two ago after posting this, it seems an Authenticated user is not getting an error now, but only Anonymous users are. The only change I recall is that the User I was testing with above had just been created, so thinking a cache issue, but not positive on that since I was tweaking the ACLs in WordPress. I've currently turned the 'Display errors' off in my PHP until I found a solution since the warning was to Anonymous subscribers only now and...first appearances are everything. ;-) Let me look up my current settings... – ChaosBuster Feb 6 '18 at 19:02
  • NOTE: I can update the problem above to not indicate a problem with Authenticated users once we find the resolution for Anonymous users. – ChaosBuster Feb 6 '18 at 19:04
  • Will combine WordPress ACL roles of Editor, Author, Contributor and Subscriber into one Authenticated user below for indicating the ACLs. – ChaosBuster Feb 6 '18 at 19:06
  • CiviCRM: edit groups Create new groups, edit group settings (e.g. group name, visibility...), delete groups: Authenticated (None), Anonymous(None) – ChaosBuster Feb 6 '18 at 19:08
1

I can confirm the warning on a vanilla CiviCRM install. Creating an ACL for the mailing list group(s) fixes it, but that doesn't seem right because:

The anonymous role (public in Joomla!) applies to all visitors to the website who have not logged in. This role will have the lowest level of permissions. The default CiviCRM permissions for this role are [...] subscribe and unsubscribe from mailing lists https://docs.civicrm.org/user/en/latest/initial-set-up/permissions-and-access-control/

So in principle this shouldn't be necessary.

The problem actually lies in the CRM_ACL_BAO_ACL::group() method because the cache returns NULL rather than an empty array. This then gets passed back unchecked to CRM_ACL_API::groupPermission() where the warning is issued.

Two options for you then:

  • Raise an issue on Jira and get the problem fixed
  • Suppress warnings and write them to a log file instead

Doing both would be the responsible way to go :-)

  • Thanks, Christian, for confirming. Have already done the 2nd suggestion and will raise the issue in Jira for the long-term resolution. Will also change the original problem to indicate the problem was with Anonymous users only. – ChaosBuster Feb 8 '18 at 19:15
  • @ChaosBuster Post the link to the Jira issue and I can help resolve it. – Christian Wach Feb 12 '18 at 14:40
  • Hmm, I did last week...let me recheck to see. It should have the same title with 'Anonymous user only' addition. – ChaosBuster Feb 12 '18 at 16:31
  • Here it is: issues.civicrm.org/jira/browse/CRM-21757 – ChaosBuster Feb 12 '18 at 16:35
  • Let me know if there are parameters that I did not 'chose wisely' for it to be found or assigned. ;-) – ChaosBuster Feb 12 '18 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.