r102007 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102006‎ | r102007 | r102008 >
Date:16:40, 4 November 2011
Author:ialex
Status:ok
Tags:
Comment:
And while I'm at it, move token check to onView() so that if action=markpatrolled is called without parameters, the user will see 'markedaspatrollederror' error and not 'sessionfailure'
Modified paths:
  • /trunk/phase3/includes/actions/MarkpatrolledAction.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/actions/MarkpatrolledAction.php
@@ -36,23 +36,22 @@
3737 return '';
3838 }
3939
40 - protected function checkCanExecute( User $user ) {
41 - if ( !$user->matchEditToken( $this->getRequest()->getVal( 'token' ), $this->getRequest()->getInt( 'rcid' ) ) ) {
42 - throw new ErrorPageError( 'sessionfailure-title', 'sessionfailure' );
43 - }
44 -
45 - return parent::checkCanExecute( $user );
46 - }
47 -
4840 public function onView() {
49 - $rc = RecentChange::newFromId( $this->getRequest()->getInt( 'rcid' ) );
 41+ $request = $this->getRequest();
5042
 43+ $rcId = $request->getInt( 'rcid' );
 44+ $rc = RecentChange::newFromId( $rcId );
5145 if ( is_null( $rc ) ) {
5246 throw new ErrorPageError( 'markedaspatrollederror', 'markedaspatrollederrortext' );
5347 }
5448
55 - $errors = $rc->doMarkPatrolled( $this->getUser() );
 49+ $user = $this->getUser();
 50+ if ( !$user->matchEditToken( $request->getVal( 'token' ), $rcId ) ) {
 51+ throw new ErrorPageError( 'sessionfailure-title', 'sessionfailure' );
 52+ }
5653
 54+ $errors = $rc->doMarkPatrolled( $user );
 55+
5756 if ( in_array( array( 'rcpatroldisabled' ), $errors ) ) {
5857 throw new ErrorPageError( 'rcpatroldisabled', 'rcpatroldisabledtext' );
5958 }

Sign-offs

UserFlagDate
Nikerabbitinspected14:08, 5 November 2011

Status & tagging log