Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-12541

Fatal error on contribution form when site has a contact subtype called 'Member'

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Cannot Reproduce
    • Affects Version/s: 4.2.9
    • Fix Version/s: 4.7
    • Component/s: None
    • Labels:
      None
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      To reproduce
      1) create a contact subtype called 'Member' that extends the contact type 'Organization'
      2) Create a contribution page, include a profile with a custom field that extends the entity_type 'Member'
      3) Fill in & submit the form as a user who does not have the subtype 'Member'

      This results in a fatal error

      sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php(101): CRM_Core_Error::fatal("The Contact Sub Type does not match the Contact type for this record")

      However, the problem stems from when the form is built. A field 'contact_sub_type_hidden' => 'Member' is added in the code below.

      I suspect the fix is to make edit the 'name' column to not exactly match 'Member' (or other types) when the label is set to 'Member'

      CRM_Core_BAO_UFGroup::buildProfile

      static $hiddenSubtype = FALSE;
      if (!$hiddenSubtype && CRM_Contact_BAO_ContactType::isaSubType($field['field_type'])) {
      // In registration mode params are submitted via POST and we don't have any clue
      // about profile-id or the profile-type (which could be a subtype)
      // To generalize the behavior and simplify the process,
      // lets always add the hidden
      //subtype value if there is any, and we won't have to
      // compute it while processing.
      if ($onBehalf)

      { $form->addElement('hidden', 'onbehalf[contact_sub_type]', $field['field_type']); }

      else

      { $form->addElement('hidden', 'contact_sub_type_hidden', $field['field_type']); }

      $hiddenSubtype = TRUE;
      }

        Attachments

          Activity

            People

            • Assignee:
              Sudha Sudha Bisht
              Reporter:
              eileen Eileen McNaughton
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: