Index: trunk/phase3/includes/RecentChange.php |
— | — | @@ -256,8 +256,9 @@ |
257 | 257 | $change = $change instanceof RecentChange |
258 | 258 | ? $change |
259 | 259 | : RecentChange::newFromId($change); |
260 | | - if(!$change instanceof RecentChange) |
| 260 | + if( !$change instanceof RecentChange ) { |
261 | 261 | return null; |
| 262 | + } |
262 | 263 | return $change->doMarkPatrolled( $auto ); |
263 | 264 | } |
264 | 265 | |
— | — | @@ -273,22 +274,34 @@ |
274 | 275 | $errors = array(); |
275 | 276 | // If recentchanges patrol is disabled, only new pages |
276 | 277 | // can be patrolled |
277 | | - if(!$wgUseRCPatrol && (!$wgUseNPPatrol || $this->getAttribute('rc_type') != RC_NEW)) |
| 278 | + if ( !$wgUseRCPatrol |
| 279 | + && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) ) |
| 280 | + { |
278 | 281 | $errors[] = array('rcpatroldisabled'); |
279 | | - $errors = array_merge($errors, $this->getTitle()->getUserPermissionsErrors('patrol', $wgUser)); |
| 282 | + } |
| 283 | + |
| 284 | + // Automatic patrol needs "autopatrol", ordinary patrol needs "patrol" |
| 285 | + $right = $auto ? 'autopatrol' : 'patrol'; |
| 286 | + $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $wgUser ) ); |
280 | 287 | if( !wfRunHooks('MarkPatrolled', array($this->getAttribute('rc_id'), &$wgUser, false)) ) |
281 | | - $errors[] = array('hookaborted'); |
| 288 | + $errors[] = array('hookaborted'); |
| 289 | + |
282 | 290 | // Users without the 'autopatrol' right can't patrol their |
283 | 291 | // own revisions |
284 | 292 | if( $wgUser->getName() == $this->getAttribute('rc_user_text') && !$wgUser->isAllowed('autopatrol') ) |
285 | 293 | $errors[] = array('markedaspatrollederror-noautopatrol'); |
286 | | - if( !empty($errors) ) |
| 294 | + |
| 295 | + if( $errors ) { |
287 | 296 | return $errors; |
| 297 | + } |
| 298 | + |
288 | 299 | // If the change was patrolled already, do nothing |
289 | 300 | if( $this->getAttribute('rc_patrolled') ) |
290 | 301 | return array(); |
| 302 | + |
291 | 303 | // Actually set the 'patrolled' flag in RC |
292 | 304 | $this->reallyMarkPatrolled(); |
| 305 | + |
293 | 306 | // Log this patrol event |
294 | 307 | PatrolLog::record( $this, $auto ); |
295 | 308 | wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$wgUser, false) ); |
— | — | @@ -415,7 +428,7 @@ |
416 | 429 | 'newSize' => $size |
417 | 430 | ); |
418 | 431 | $rc->save(); |
419 | | - return( $rc->mAttribs['rc_id'] ); |
| 432 | + return $rc; |
420 | 433 | } |
421 | 434 | |
422 | 435 | # Makes an entry in the database corresponding to a rename |