When a user inserts its secret code the account creation fail. The module registers this error in the log:

Invalid argument supplied for foreach() en la línea 1374 del archivo /var/www/drupal-5.2/sites/test.gulic.org/modules/ldap_provisioning/ldapprov.module.

I attach a patch to solve this problem.

CommentFileSizeAuthor
ldapprov.module_0.patch376 bytesjesustorres
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

miglius’s picture

Assigned: Unassigned » miglius
Status: Active » Fixed

Thanks for spotting this bug.

The actual ldap creation error was to the fact that Last name (sn in ldap) is a required attribute. So if last name is not set I set sn attribute in ldap to the username value. Also have fixed the foreach statement.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

ckng’s picture

Version: » 5.x-1.x-dev
Status: Closed (fixed) » Reviewed & tested by the community

miglius,
I reopen the issue as it seems the patch is not yet in the cvs nor in the latest release.

miglius’s picture

The code which you want to change in the patch

  foreach ($edit as $key => $value) {
    if (preg_match("/(^profile_|^ldap_|^custom_)/", $key)) {
      $data[$key] = $value;
    }
  }

constructs a $data array with a registration form submitted data which will be saved in the db for the account approver to be able to review it. The problem is that under certain configuration (if we request only username and email in the registration form) the $data array might not be defined. If I apply your patch, then all hidden form elements, captcha answer (if captcha module is enabled) would be saved in the db, which is unnecessary.

The error says about empty array in line 1374. To fix it I have added a check if the array is not empty before foreach statement:

      unset($edit['roles']);
      if (is_array(unserialize($row->data))) {
        foreach (unserialize($row->data) as $k => $v) {
          $edit[$k] = $v;
        }      
      }

Can you just check with the latest code if you still are getting the warning in the log?

  • Commit 81bc5f1 on 5.x-1.x, master, 6.x-2.x, 6.x-1.x by miglius:
    #183734 fixing error when creating a new account
    
    

  • Commit 81bc5f1 on 5.x-1.x, master, 6.x-2.x, 6.x-1.x by miglius:
    #183734 fixing error when creating a new account