CRM-3542 CiviCRM (still) does not correctly use drupal's hook_user

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      As noted above the function:

      • Note that we ignore the edit field and do not follow the drupal protocol
      • of extracting values from the edit field. We extract the fields directly
      • from $_POST. This is because the underlying form package that we use
      • (HTML_QuickForm) does the form value extraction and validation.

      However this incorrectly assumes that the use object is only modified via the user account form. Several modules modify the user object directly via user_save. CiviCRM's implementation of hook_user does not follow the rules for the $edit argument, and thus does not update the email address when altered programatically (without the account form).

        Attachments

          Activity

          [CRM-3542] CiviCRM (still) does not correctly use drupal's hook_user
          Jonathan Hedstrom added a comment -

          Sorry, I incorrectly used the clone method.

          I wanted to re-open this issue, since there is still a problem with the implementation of hook_user. On the $op == 'form' part of the hook, the civicrm_user function is incorrectly trying to output a form for /all/ modules that implement this hook:

          <code>
          case 'form':
          // only return a form to drupal my account page
          if ( arg(0) == 'user' &&
          arg(2) == 'edit' &&
          arg(3) ) {
          if ( empty( $_POST ) )

          { return civicrm_form_data($edit, $user, $category, true, false ); }

          else

          { return civicrm_form_data($edit, $user, $category, true, true ); }

          }
          break;
          </code>

          This hook should only return a form for categories that civicrm knows about. As it is, it results in errors for any other module trying to output a form here.

          Donald A. Lobo added a comment -


          please submit a patch for this issue. I suspect you know way more about this issue and a potential patch than we do. If submitted in the next day or so we can include it in the 2.1, else we will push to 2.2

          Jonathan Hedstrom added a comment -

          Here's a patch that fixes the issue, but could use a review with an eye towards civicrm integration...having to cycle through the array of categories just to get a linear array seems a bit cludgy.

          dave hansen-lange added a comment -

          That makes sense. I guess I haven't come across the issue since in my recent sites I don't have any other modules that present user forms. I think your general idea is sound.

          I had this wonderful idea to reduce the cludginess, but it ended up being 2 lines longer than your suggestion. Lobo any ideas to make that array search look cleaner?

          Donald A. Lobo added a comment -


          I tweaked the patch slightly and applied it to the 2.1 branch. Should be part of the next release

          Kurund Jalmi added a comment -
          • verified in rev 18942.

            People

            • Assignee:
              Neha Kulkarni
              Reporter:
              Jonathan Hedstrom

              Dates

              • Created:
                Updated:
                Resolved: