global variable name causing functionality problems

kreaper - July 9, 2007 - 19:25
Project:LDAP integration
Version:5.x-1.2
Component:Code
Category:bug report
Priority:critical
Assigned:kreaper
Status:closed
Description

Please see if this makes sense:

The ldapauth.module uses a global variable name called "ldap" to instantiate new LDAP objects. It also happens that the ldapdata module also uses the same global variable name "ldap".

In ldapauth.module, the function _ldapauth_save_user invokes the hook user_load and later on uses the global variable $ldap values to save ldap_config info to the user object. However, user_load invokes ldapdata.module as it provides that hook, which over rides the values in the global $ldap object.

This problem is visible in the following environment:

  • Multiple LDAP Server Configs are in place and enabled
  • User account is not found in the first config but in the later configs

This will cause the global $ldap object to lose its correct server info and get reset in the ldapdata.module.

FIX:

  • Follow good coding practices and rename the global variable to module-specific variable. (i.e. Rename $ldap to $ldapauth_ldap

I will provide a patch fix and I wanted to post the info so that others can comment and agree/disagree.

kreaper

#1

kreaper - July 10, 2007 - 01:13

ldapdata.module.patch attached

AttachmentSize
ldapdata.module.patch 534 bytes

#2

kreaper - July 10, 2007 - 01:15

ldapauth.module.patch attached

AttachmentSize
ldapauth.module_1.patch 6.67 KB

#3

kreaper - July 10, 2007 - 03:34

ldapgroups.module.patch

AttachmentSize
ldapgroups.module.patch 4.72 KB

#4

kreaper - July 22, 2007 - 19:51
Status:active» closed

Committing to HEAD

 
 

Drupal is a registered trademark of Dries Buytaert.