Index: trunk/extensions/CentralAuth/ApiQueryGlobalUserInfo.php |
— | — | @@ -42,37 +42,40 @@ |
43 | 43 | $params['user'] = $wgUser->getName(); |
44 | 44 | } |
45 | 45 | $user = new CentralAuthUser( $params['user'] ); |
46 | | - if ( !$user->exists() ) { |
47 | | - $this->dieUsageMsg( array( 'nosuchuser', $params['user'] ) ); |
48 | | - } |
49 | 46 | |
50 | 47 | // Add basic info |
51 | 48 | $result = $this->getResult(); |
52 | | - $data = array( |
53 | | - 'home' => $user->getHomeWiki(), |
54 | | - 'id' => $user->getId(), |
55 | | - 'registration' => wfTimestamp( TS_ISO_8601, $user->getRegistration() ) |
56 | | - ); |
57 | | - if ( $user->isLocked() ) { |
58 | | - $data['locked'] = ''; |
| 49 | + $data = array(); |
| 50 | + $userExists = $user->exists(); |
| 51 | + |
| 52 | + if ( $userExists ) { |
| 53 | + $data['home'] = $user->getHomeWiki(); |
| 54 | + $data['id'] = $user->getId(); |
| 55 | + $data['registration'] = wfTimestamp( TS_ISO_8601, $user->getRegistration() ); |
| 56 | + |
| 57 | + if ( $user->isLocked() ) { |
| 58 | + $data['locked'] = ''; |
| 59 | + } |
| 60 | + if ( $user->isHidden() ) { |
| 61 | + $data['hidden'] = ''; |
| 62 | + } |
| 63 | + } else { |
| 64 | + $data['missing'] = ''; |
59 | 65 | } |
60 | | - if ( $user->isHidden() ) { |
61 | | - $data['hidden'] = ''; |
62 | | - } |
63 | 66 | $result->addValue( 'query', $this->getModuleName(), $data ); |
64 | 67 | |
65 | 68 | // Add requested info |
66 | | - if ( isset( $prop['groups'] ) ) { |
| 69 | + if ( $userExists && isset( $prop['groups'] ) ) { |
67 | 70 | $groups = $user->getGlobalGroups(); |
68 | 71 | $result->setIndexedTagName( $groups, 'g' ); |
69 | 72 | $result->addValue( array( 'query', $this->getModuleName() ), 'groups', $groups ); |
70 | 73 | } |
71 | | - if ( isset( $prop['rights'] ) ) { |
| 74 | + if ( $userExists && isset( $prop['rights'] ) ) { |
72 | 75 | $rights = $user->getGlobalRights(); |
73 | 76 | $result->setIndexedTagName( $rights, 'r' ); |
74 | 77 | $result->addValue( array( 'query', $this->getModuleName() ), 'rights', $rights ); |
75 | 78 | } |
76 | | - if ( isset( $prop['merged'] ) ) { |
| 79 | + if ( $userExists && isset( $prop['merged'] ) ) { |
77 | 80 | $accounts = $user->queryAttached(); |
78 | 81 | foreach ( $accounts as $account ) { |
79 | 82 | $a = array( |
— | — | @@ -152,12 +155,6 @@ |
153 | 156 | return 'Show information about a global user.'; |
154 | 157 | } |
155 | 158 | |
156 | | - public function getPossibleErrors() { |
157 | | - return array_merge( parent::getPossibleErrors(), array( |
158 | | - array( 'nosuchuser', 'user' ), |
159 | | - ) ); |
160 | | - } |
161 | | - |
162 | 159 | protected function getExamples() { |
163 | 160 | return array( |
164 | 161 | 'api.php?action=query&meta=globaluserinfo', |