r96043 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96042‎ | r96043 | r96044 >
Date:21:20, 1 September 2011
Author:laner
Status:deferred (Comments)
Tags:
Comment:
Add helper functions
Modified paths:
  • /trunk/extensions/LdapAuthentication/LdapAuthentication.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php
@@ -1105,9 +1105,8 @@
11061106 return $this->userInfo;
11071107 }
11081108
1109 - $entry = @ldap_read( $this->ldapconn, $this->userdn, "objectclass=*", array( '*', 'memberof' ) );
1110 - $userInfo = @ldap_get_entries( $this->ldapconn, $entry );
1111 - if ( $userInfo["count"] < 1 ) {
 1109+ $userInfo = $this->getUserInfoStateless( $this->usernn );
 1110+ if ( is_null( $userInfo ) ) {
11121111 $this->fetchedUserInfo = false;
11131112 return;
11141113 } else {
@@ -1116,6 +1115,32 @@
11171116 }
11181117 }
11191118
 1119+ function getUserInfoStateless( $userdn ) {
 1120+ // Don't fetch the same data more than once
 1121+ // TODO: use memcached here
 1122+
 1123+ $entry = @ldap_read( $this->ldapconn, $userdn, "objectclass=*", array( '*', 'memberof' ) );
 1124+ $userInfo = @ldap_get_entries( $this->ldapconn, $entry );
 1125+ if ( $userInfo["count"] < 1 ) {
 1126+ return;
 1127+ } else {
 1128+ return $userInfo;
 1129+ }
 1130+ }
 1131+
 1132+ function getSearchAttribute() {
 1133+ global $wgLDAPSearchAttributes;
 1134+
 1135+ // Return the search attribute configured, mainly for use in other
 1136+ // extensions
 1137+ // TODO: make function to pull any configuration item
 1138+ if ( isset( $wgLDAPSearchAttributes[$_SESSION['wsDomain']] ) ) {
 1139+ return $wgLDAPSearchAttributes[$_SESSION['wsDomain']];
 1140+ } else {
 1141+ return '';
 1142+ }
 1143+ }
 1144+
11201145 /**
11211146 * Retrieve user preferences from LDAP
11221147 *

Comments

#Comment by 😂 (talk | contribs)   22:02, 1 September 2011

@ is evil, can you use wfSuppressWarnings/wfRestoreWarnings?

#Comment by Ryan lane (talk | contribs)   23:25, 1 September 2011

Yes. This codebase is really old and there are like 1-023485p082354-0823-508243-05 of them in there. I'll take them all out one day.

Status & tagging log