CRM-18776 Views and non-Contact entities with custom field groups

    Details

    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      If a custom group for an entity that isn't a contact includes anything in the extends_entity_column_value, then Drupal Views is broken (e.g. you get an error on the views admin page).

      This appears to have been triggered by some additional security bits in the latest releases, and is particularly obvious with civivolunteer installed. I don't know why civivolunteer is including anything in that column and/or whether it should, but the important bit is that the views code seems to assume that that field is a contact subtype.

      I'll attach a patch that is working for me.

        Attachments

          Issue Links

            Activity

            [CRM-18776] Views and non-Contact entities with custom field groups
            Alan Dixon added a comment -
            KarinG added a comment -

            Hey Frank J. Gómez and Eileen McNaughton - just wanted to bring Alan's patch to your attention - if you could QA it [and better - get it in the repo] that would be great!

            Eileen McNaughton added a comment -

            Looking at your patch I'm not sure if it would (or is intended to) address the specific variation I hit - ie. the data was '~~' where ~ is the custom data separator so

            explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->extends_entity_column_value);

            Would still return 2 rows in the array because there are 2 separators - & that is still incorrect.

            I do agree that we should pass correct information into the function & the business of the function accepting a string or an array is just ugly.

            Alan Dixon added a comment -

            Yes, there are a few things going wrong right now, but I believe your specific symptom is the same as mine and the real issue is that it's passing in an argument for a subtype when the entity is not a contact (i.e. it's a Activity).

            But yes, I could also convert the empty array argument into NULL if that's better.

            Eileen McNaughton added a comment -

            I'm OK with the empty array but my worry is you might wind up with an array like

            array(
            0 => '',
            1 => '',
            );

            With the specific data set I was referring to - ie. a field with 2 * custom separators & nothing else in it.

            Maybe that doesn't matter - if you say your patch works in that case then I think it is probably fine.

            Alan Dixon added a comment - - edited

            Great, I added in a little array_filter to get rid of any empty array elements, PR is
            https://github.com/civicrm/civicrm-drupal/pull/386

            I made my pull request to 7.x-master, not sure if I should be doing the same for other 7.x (and 6.x branches for that matter). The code change should apply to several versions back of civicrm for correctness, but it's only necessary since the last couple of security releases.

            Frank J. Gómez added a comment -

            I commented on GitHub and SE. I wasn't sure exactly what the problem was (more explicit reproduction steps would allow me to test the patch locally), but hopefully something I typed will provide some background. Let me know if I can be of further help.

            Alan Dixon added a comment -

            re: reproducing it - my two reports both came from Drupal 7 + CiviCRM 4.6 with your latest Volunteer extension, and the symptom was a 500 error on a block and/or view admin page.

            Eileen McNaughton added a comment -

            I believe this is a problem that was fixed. It can still recur if there is invalid data in the civicrm_custom_group table for extending subtypes but I think we have fixed the instances of invalid data.

            I think we should close this, unless you can verify it is still occurring, as a duplicate

            Naomi Rosenberg added a comment -

            I was getting this error:

            CRM_Core_Exception: Invalid Entity Filter in CRM_Core_BAO_CustomGroup::validateSubTypeByEntity()

            And the views admin page was missing.

            I applied the patch and it fixed it. Thanks! My Civi version is up to date so I suspect this IS still a problem - unless I have corrupt date in my custom fields table.

            Eileen, would you be able to tell me what sort of corruption it might be and how I can find it? Ta!

            Alan Dixon added a comment -

            Naomi - did you also apply the patch at https://issues.civicrm.org/jira/browse/CRM-19545 ?

            Looks like this one is slightly inadequate (i.e. if you've got custom fields on any of the contact types beyond the base type).

            Eileen - my recollection is that the patch is worthwhile even if the specific causes have been resolved - i.e. the current code itself is wrong. But clearly it needs more testing ...

            Naomi Rosenberg added a comment -

            Alan - thanks, no I haven't but I'm not actually doing any views integration. What I needed to fix was the error happening on cache clear and the missing Views admin page. I'll bear it in mind though.

            Eileen McNaughton added a comment -

            Alan Dixon - looks like that PR is stuck on needing a change made & needing testing. Not sure if Urlisse is going to pick that up or not. If you want to pick it up then you could submit an alternate PR with testing notes. I wouldn't need another reviewer to review your PR as you would be the reviewer

            Eileen McNaughton added a comment -

            Naomi Rosenberg - "I applied the patch and it fixed it. Thanks! My Civi version is up to date so I suspect this IS still a problem - unless I have corrupt date in my custom fields table." - which patch was that?

            John Kirk added a comment -

            Eileen McNaughton The patch https://github.com/civicrm/civicrm-drupal/commit/e9eca96138966352162a5ab0bc2f873172854591 stops the Views UI from containing custom fields. Undoing this patch makes it work. This is without CiviCRM Entity installed. Drupal 7.

              People

              • Assignee:
                Alan Dixon
                Reporter:
                Alan Dixon

                Dates

                • Created:
                  Updated:
                  Resolved: