Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -239,6 +239,9 @@ |
240 | 240 | * (bug 27897) list=allusers and list=users list hidden users |
241 | 241 | * (bug 27717) API's exturlusage module does not respect $wgMiserMode |
242 | 242 | * (bug 27588) list=filearchive&faprop=sha1 returns empty attribute |
| 243 | +* (bug 28010) Passing a non existant user to list=users gives internal error |
| 244 | +* (bug 27549) action=query&list=users&usprop=groups doesn't show implicit |
| 245 | + groups if a user doesn't have explicit groups |
243 | 246 | |
244 | 247 | === Languages updated in 1.18 === |
245 | 248 | |
Index: trunk/phase3/includes/api/ApiQueryUsers.php |
— | — | @@ -109,12 +109,14 @@ |
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
| 113 | + $result = $this->getResult(); |
| 114 | + |
113 | 115 | if ( count( $goodNames ) ) { |
114 | 116 | $this->addTables( 'user' ); |
115 | 117 | $this->addFields( '*' ); |
116 | 118 | $this->addWhereFld( 'user_name', $goodNames ); |
117 | 119 | |
118 | | - if ( isset( $this->prop['groups'] ) ) { |
| 120 | + if ( isset( $this->prop['groups'] ) || isset( $this->prop['rights'] ) ) { |
119 | 121 | $this->addTables( 'user_groups' ); |
120 | 122 | $this->addJoinConds( array( 'user_groups' => array( 'LEFT JOIN', 'ug_user=user_id' ) ) ); |
121 | 123 | $this->addFields( 'ug_group' ); |
— | — | @@ -125,8 +127,6 @@ |
126 | 128 | $data = array(); |
127 | 129 | $res = $this->select( __METHOD__ ); |
128 | 130 | |
129 | | - $result = $this->getResult(); |
130 | | - |
131 | 131 | foreach ( $res as $row ) { |
132 | 132 | $user = User::newFromRow( $row ); |
133 | 133 | $name = $user->getName(); |
— | — | @@ -142,24 +142,26 @@ |
143 | 143 | $data[$name]['registration'] = wfTimestampOrNull( TS_ISO_8601, $user->getRegistration() ); |
144 | 144 | } |
145 | 145 | |
146 | | - if ( isset( $this->prop['groups'] ) && !is_null( $row->ug_group ) ) { |
147 | | - if ( !isset( $data[$u]['groups'] ) ) { |
148 | | - $data[$u]['groups'] = ApiQueryUsers::getAutoGroups( User::newFromName( $u ) ); |
| 146 | + if ( isset( $this->prop['groups'] ) ) { |
| 147 | + if ( !isset( $data[$name]['groups'] ) ) { |
| 148 | + $data[$name]['groups'] = self::getAutoGroups( $user ); |
149 | 149 | } |
150 | 150 | |
151 | | - // This row contains only one group, others will be added from other rows |
152 | | - $data[$name]['groups'][] = $row->ug_group; |
153 | | - $result->setIndexedTagName( $data[$u]['groups'], 'g' ); |
| 151 | + if ( !is_null( $row->ug_group ) ) { |
| 152 | + // This row contains only one group, others will be added from other rows |
| 153 | + $data[$name]['groups'][] = $row->ug_group; |
| 154 | + } |
154 | 155 | } |
155 | 156 | |
156 | | - if ( isset( $this->prop['rights'] ) && !is_null( $row->ug_group ) ) { |
| 157 | + if ( isset( $this->prop['rights'] ) ) { |
157 | 158 | if ( !isset( $data[$name]['rights'] ) ) { |
158 | 159 | $data[$name]['rights'] = User::getGroupPermissions( User::getImplicitGroups() ); |
159 | 160 | } |
160 | 161 | |
161 | | - $data[$name]['rights'] = array_unique( array_merge( $data[$name]['rights'], |
162 | | - User::getGroupPermissions( array( $row->ug_group ) ) ) ); |
163 | | - $result->setIndexedTagName( $data[$name]['rights'], 'r' ); |
| 162 | + if ( !is_null( $row->ug_group ) ) { |
| 163 | + $data[$name]['rights'] = array_unique( array_merge( $data[$name]['rights'], |
| 164 | + User::getGroupPermissions( array( $row->ug_group ) ) ) ); |
| 165 | + } |
164 | 166 | } |
165 | 167 | if ( $row->ipb_deleted ) { |
166 | 168 | $data[$name]['hidden'] = ''; |
— | — | @@ -195,6 +197,7 @@ |
196 | 198 | } |
197 | 199 | } |
198 | 200 | } |
| 201 | + |
199 | 202 | // Second pass: add result data to $retval |
200 | 203 | foreach ( $goodNames as $u ) { |
201 | 204 | if ( !isset( $data[$u] ) ) { |
— | — | @@ -220,6 +223,13 @@ |
221 | 224 | } else { |
222 | 225 | $data[$u]['missing'] = ''; |
223 | 226 | } |
| 227 | + } else { |
| 228 | + if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) { |
| 229 | + $result->setIndexedTagName( $data[$u]['groups'], 'g' ); |
| 230 | + } |
| 231 | + if ( isset( $this->prop['rights'] ) && isset( $data[$u]['rights'] ) ) { |
| 232 | + $result->setIndexedTagName( $data[$u]['rights'], 'r' ); |
| 233 | + } |
224 | 234 | } |
225 | 235 | |
226 | 236 | $fit = $result->addValue( array( 'query', $this->getModuleName() ), |
— | — | @@ -231,7 +241,7 @@ |
232 | 242 | } |
233 | 243 | $done[] = $u; |
234 | 244 | } |
235 | | - return $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'user' ); |
| 245 | + return $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'user' ); |
236 | 246 | } |
237 | 247 | |
238 | 248 | /** |