With HEAD version downloaded March 3, 2007
// $Id: ldapdata.module,v 1.11 2007/03/03 03:23:56 scafmac Exp $

LDAP user login fails with whitescreen and this error:

Fatal error: Cannot use object of type stdClass as array in
/srv/www/drupal-5.1/modules/ldap_integration/ldapdata.module on line 529

Comments

rar’s picture

Also occurs when trying to edit a user: ( http://localhost/user/2/edit )

rar’s picture

Title: Login fatal error: » Login fatal error: solution/patch
Status: Active » Reviewed & tested by the community

Modify lines 527-529

from:
> $result = db_fetch_array(db_query("SELECT fid FROM {profile_fields} WHERE name = '%s'", $field));
> $fid = $result['fid'];
> $uid = $user['uid'];

to:
< $result = db_fetch_array(db_query("SELECT fid,uid FROM {profile_fields} WHERE name = '%s'", $field));
< $fid = $result['fid'];
< $uid = $result['uid'];

rar’s picture

Status: Reviewed & tested by the community » Needs review
rar’s picture

Oops - too quick on the submit button - should be

Modify line 529 only

from:
$uid = $user['uid'];

to:
$uid = $user->uid;

scafmac’s picture

Assigned: Unassigned » scafmac

Thanks - will commit the patch to head shortly.

scafmac’s picture

Rar,

I'm unable to duplicate the problem, though it is clearly a problem. Will you test something for me? Return the select statement to the original syntax (including uid) and then change $user->uid to $result['uid'] on line 529. Does that work?

Thanks

scafmac’s picture

I don't believe you should be using the global user variable for the source of the uid. The uid should come from the profile table. So as you noted originally, the select statement and the $user assignment statement need to be fixed.

I've changed it and am testing it. I'll commit it to head shortly.

rar’s picture

But 'uid' doesn't exist in the table profile_fields. I.e.

show create table profile_fields;

| Table          | Create Table                              |
| profile_fields | CREATE TABLE `profile_fields` (
  `fid` int(11) NOT NULL auto_increment,
  `title` varchar(255) default NULL,
  `name` varchar(128) default NULL,
  `explanation` text,
  `category` varchar(255) default NULL,
  `page` varchar(255) default NULL,
  `type` varchar(128) default NULL,
  `weight` tinyint(4) NOT NULL default '0',
  `required` tinyint(4) NOT NULL default '0',
  `register` tinyint(4) NOT NULL default '0',
  `visibility` tinyint(4) NOT NULL default '0',
  `autocomplete` tinyint(4) NOT NULL default '0',
  `options` text,
  PRIMARY KEY  (`fid`),
  UNIQUE KEY `name` (`name`),
  KEY `category` (`category`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
scafmac’s picture

Status: Needs review » Closed (fixed)

That'll teach me to stop multitasking at work - You're absolutely correct; I was looking at profile_values instead and didn't see that $user was passed in.

Anyhow thanks for the catch. It is fixed in HEAD.