r96044 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96043‎ | r96044 | r96045 >
Date:21:26, 1 September 2011
Author:laner
Status:ok
Tags:
Comment:
* Remove hack in OpenStackNovaUser.php that searches for user dn's improperly in some cases
* Add userInfo search to project and role member lists
** This has a nasty performance penalty, but is required. Memcache support here would fix this
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackNovaProject.php (modified) (history)
  • /trunk/extensions/OpenStackManager/OpenStackNovaRole.php (modified) (history)
  • /trunk/extensions/OpenStackManager/OpenStackNovaUser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/OpenStackNovaRole.php
@@ -77,15 +77,26 @@
7878 * @return array
7979 */
8080 function getMembers() {
 81+ global $wgAuth;
 82+
8183 $members = array();
8284 if ( isset( $this->roleInfo[0]['member'] ) ) {
8385 $memberdns = $this->roleInfo[0]['member'];
8486 array_shift( $memberdns );
8587 foreach ( $memberdns as $memberdn ) {
86 - $member = explode( '=', $memberdn );
87 - $member = explode( ',', $member[1] );
88 - $member = $member[0];
89 - $members[] = $member;
 88+ $searchattr = $wgAuth->getSearchAttribute();
 89+ if ( $searchattr ) {
 90+ // We need to look up the search attr from the user entry
 91+ // this is expensive, but must be done.
 92+ // TODO: memcache this
 93+ $userInfo = $wgAuth->getUserInfoStateless( $memberdn );
 94+ $members[] = $userInfo[0][$searchattr][0];
 95+ } else {
 96+ $member = explode( '=', $memberdn );
 97+ $member = explode( ',', $member[1] );
 98+ $member = $member[0];
 99+ $members[] = $member;
 100+ }
90101 }
91102 }
92103
Index: trunk/extensions/OpenStackManager/OpenStackNovaProject.php
@@ -73,15 +73,26 @@
7474 * @return array
7575 */
7676 function getMembers() {
 77+ global $wgAuth;
 78+
7779 $members = array();
7880 if ( isset( $this->projectInfo[0]['member'] ) ) {
7981 $memberdns = $this->projectInfo[0]['member'];
8082 array_shift( $memberdns );
8183 foreach ( $memberdns as $memberdn ) {
82 - $member = explode( '=', $memberdn );
83 - $member = explode( ',', $member[1] );
84 - $member = $member[0];
85 - $members[] = $member;
 84+ $searchattr = $wgAuth->getSearchAttribute();
 85+ if ( $searchattr ) {
 86+ // We need to look up the search attr from the user entry
 87+ // this is expensive, but must be done.
 88+ // TODO: memcache this
 89+ $userInfo = $wgAuth->getUserInfoStateless( $memberdn );
 90+ $members[] = $userInfo[0][$searchattr][0];
 91+ } else {
 92+ $member = explode( '=', $memberdn );
 93+ $member = explode( ',', $member[1] );
 94+ $member = $member[0];
 95+ $members[] = $member;
 96+ }
8697 }
8798 }
8899
Index: trunk/extensions/OpenStackManager/OpenStackNovaUser.php
@@ -20,12 +20,13 @@
2121 */
2222 function fetchUserInfo() {
2323 global $wgAuth, $wgUser;
24 - global $wgOpenStackManagerLDAPUseUidAsNamingAttribute;
2524
26 - if ( $this->username && !$wgOpenStackManagerLDAPUseUidAsNamingAttribute ) {
 25+ if ( $this->username ) {
2726 $this->userDN = $wgAuth->getUserDN( strtolower( $this->username ) );
 27+ $wgAuth->printDebug( "Fetching userdn using username: $this->userDN ", NONSENSITIVE );
2828 } else {
2929 $this->userDN = $wgAuth->getUserDN( strtolower( $wgUser->getName() ) );
 30+ $wgAuth->printDebug( "Fetching userdn using wiki name: $this->userDN", NONSENSITIVE );
3031 }
3132 $this->userInfo = $wgAuth->userInfo;
3233 }

Status & tagging log