Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php |
— | — | @@ -199,6 +199,10 @@ |
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Wrapper for ldap_add |
| 203 | + * @param $ldapconn |
| 204 | + * @param $dn |
| 205 | + * @param $entry |
| 206 | + * @return bool |
203 | 207 | */ |
204 | 208 | public static function ldap_add( $ldapconn, $dn, $entry ) { |
205 | 209 | wfSuppressWarnings(); |
— | — | @@ -1366,16 +1370,19 @@ |
1367 | 1371 | * @return array|null |
1368 | 1372 | */ |
1369 | 1373 | function getUserInfoStateless( $userdn ) { |
1370 | | - // Don't fetch the same data more than once |
1371 | | - // TODO: use memcached here |
| 1374 | + global $wgMemc; |
| 1375 | + $key = wfMemcKey( 'ldapauthentication', 'userdn', $userdn ); |
1372 | 1376 | |
1373 | | - $entry = LdapAuthenticationPlugin::ldap_read( $this->ldapconn, $userdn, "objectclass=*", array( '*', 'memberof' ) ); |
1374 | | - $userInfo = LdapAuthenticationPlugin::ldap_get_entries( $this->ldapconn, $entry ); |
1375 | | - if ( $userInfo["count"] < 1 ) { |
1376 | | - return null; |
1377 | | - } else { |
1378 | | - return $userInfo; |
| 1377 | + $userInfo = $wgMemc->get( $key ); |
| 1378 | + if ( !is_array( $userInfo ) ) { |
| 1379 | + $entry = LdapAuthenticationPlugin::ldap_read( $this->ldapconn, $userdn, "objectclass=*", array( '*', 'memberof' ) ); |
| 1380 | + $userInfo = LdapAuthenticationPlugin::ldap_get_entries( $this->ldapconn, $entry ); |
| 1381 | + if ( $userInfo["count"] < 1 ) { |
| 1382 | + return null; |
| 1383 | + } |
| 1384 | + $wgMemc->set( $key, $userInfo ); |
1379 | 1385 | } |
| 1386 | + return $userInfo; |
1380 | 1387 | } |
1381 | 1388 | |
1382 | 1389 | /** |
— | — | @@ -1477,6 +1484,7 @@ |
1478 | 1485 | |
1479 | 1486 | /** |
1480 | 1487 | * Function to get the user's groups. |
| 1488 | + * @param string $username |
1481 | 1489 | */ |
1482 | 1490 | private function getGroups( $username ) { |
1483 | 1491 | $this->printDebug( "Entering getGroups", NONSENSITIVE ); |
— | — | @@ -1550,12 +1558,12 @@ |
1551 | 1559 | * $searchedgroups is used for tail recursion and shouldn't be provided |
1552 | 1560 | * when called externally. |
1553 | 1561 | * |
1554 | | - * @param string $userDN |
| 1562 | + * @param $groups |
1555 | 1563 | * @param array $searchedgroups |
1556 | 1564 | * @return bool |
1557 | 1565 | * @access private |
1558 | 1566 | */ |
1559 | | - function searchNestedGroups( $groups, $searchedgroups = array( "dn" => Array(), "short" => Array() ) ) { |
| 1567 | + function searchNestedGroups( $groups, $searchedgroups = array( "dn" => array(), "short" => array() ) ) { |
1560 | 1568 | $this->printDebug( "Entering searchNestedGroups", NONSENSITIVE ); |
1561 | 1569 | |
1562 | 1570 | // base case, no more groups left to check |