backdrop-contrib / matomo

Adds the tracking code for Matomo Analytics to your Backdrop CMS site.
https://backdropcms.org/project/matomo
GNU General Public License v2.0
3 stars 5 forks source link

Notice: Undefined index: #user_category in matomo_form_user_profile_form_alter() #1

Closed indigoxela closed 4 years ago

indigoxela commented 4 years ago

Here's the full php notice text: Notice: Undefined index: #user_category in matomo_form_user_profile_form_alter() (line 403 ...modules/matomo/matomo.module). This happens, when a user opens his/her user-profile-form at user/X/edit. This affects the form visibility for per-user opt-in/out settings.

I'm not sure if Backdrop is using _usercategory anywhere. It seems to exist in core function user_profile_form() in Drupal 7, but not in Backdrop 1.

indigoxela commented 4 years ago

As I suspected: user_category is gone for quite some time.

Here's the related Drupal change record: https://www.drupal.org/node/1393236

I've added a PR, please test and review.

indigoxela commented 4 years ago

It turned out that there's an additional problem:

https://github.com/backdrop-contrib/matomo/blob/21076749d0da7b71ed27eaf7af433e328d836758/matomo.module#L617

array_sum() works for the Drupal version as Drupal uses numeric role ids (rid). In Backdrop this has to be adapted. PR has been updated accordingly.

This fixes tracking code visibility by role.

@hosef could you have a look, please?