r77298 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77297‎ | r77298 | r77299 >
Date:20:05, 25 November 2010
Author:aaron
Status:ok
Tags:
Comment:
MFT r77276
Modified paths:
  • /branches/wmf/1.16wmf4/extensions/FlaggedRevs (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/FlaggedRevs/api/ApiReview.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/FlaggedRevs/language (modified) (history)

Diff [purge]

Property changes on: branches/wmf/1.16wmf4/extensions/FlaggedRevs/language
___________________________________________________________________
Modified: svn:mergeinfo
11 Merged /trunk/extensions/FlaggedRevs/language:r77276
Index: branches/wmf/1.16wmf4/extensions/FlaggedRevs/api/ApiReview.php
@@ -33,7 +33,7 @@
3434 * except that it generates the template and image parameters itself.
3535 */
3636 public function execute() {
37 - global $wgUser, $wgOut;
 37+ global $wgUser, $wgOut, $wgParser;
3838 $params = $this->extractRequestParams();
3939 // Check basic permissions
4040 if ( !$wgUser->isAllowed( 'review' ) ) {
@@ -52,10 +52,8 @@
5353 $title = $rev->getTitle();
5454 $form->setPage( $title );
5555 $form->setOldId( $revid );
56 - if ( FlaggedRevs::dimensionsEmpty() ) {
57 - $form->setApprove( empty( $params['unapprove'] ) );
58 - $form->setUnapprove( !empty( $params['unapprove'] ) );
59 - }
 56+ $form->setApprove( empty( $params['unapprove'] ) );
 57+ $form->setUnapprove( !empty( $params['unapprove'] ) );
6058 if ( isset( $params['comment'] ) )
6159 $form->setComment( $params['comment'] );
6260 if ( isset( $params['notes'] ) )
@@ -63,7 +61,7 @@
6462 // The flagging parameters have the form 'flag_$name'.
6563 // Extract them and put the values into $form->dims
6664 foreach ( FlaggedRevs::getTags() as $tag ) {
67 - $form->setDim( $tag, intval( $params['flag_' . $tag] ) );
 65+ $form->setDim( $tag, (int)$params['flag_' . $tag] );
6866 }
6967 if ( $form->getAction() === 'approve' ) {
7068 $parserOutput = null;
@@ -76,7 +74,6 @@
7775 }
7876 if ( !$parserOutput || !isset( $parserOutput->fr_fileSHA1Keys ) ) {
7977 // Miss, we have to reparse the page
80 - global $wgParser;
8178 $text = $article->getContent();
8279 $options = FlaggedRevs::makeParserOptions();
8380 $parserOutput = $wgParser->parse(
@@ -96,11 +93,10 @@
9794
9895 $status = $form->ready(); // all params set
9996 if ( $status === 'review_page_unreviewable' ) {
100 - $this->dieUsage( "Provided revision or page can not be reviewed.",
101 - 'notreviewable' );
 97+ $this->dieUsage( "Provided page is not reviewable.", 'notreviewable' );
10298 // Check basic page permissions
10399 } elseif ( !$title->quickUserCan( 'review' ) || !$title->quickUserCan( 'edit' ) ) {
104 - $this->dieUsage( "You don't have the necessary rights to set the specified flags.",
 100+ $this->dieUsage( "Insufficient rights to set the specified flags.",
105101 'permissiondenied' );
106102 }
107103
@@ -115,10 +111,7 @@
116112 $this->dieUsage( "Cannot find a flagged revision with the specified ID.", 'notarget' );
117113 # Approval failures
118114 } else {
119 - if ( is_array( $status ) ) {
120 - $this->dieUsage( "A sync failure has occured while reviewing. Please try again.",
121 - 'syncfailure' );
122 - } elseif ( $status === 'review_too_low' ) {
 115+ if ( $status === 'review_too_low' ) {
123116 $this->dieUsage( "Either all or none of the flags have to be set to zero.",
124117 'mixedapproval' );
125118 } elseif ( $status === 'review_denied' ) {
@@ -144,15 +137,15 @@
145138
146139 public function getAllowedParams() {
147140 $pars = array(
148 - 'revid' => null,
149 - 'token' => null,
150 - 'comment' => null,
 141+ 'revid' => null,
 142+ 'token' => null,
 143+ 'comment' => null,
 144+ 'unapprove' => false
151145 );
152 - if ( FlaggedRevs::allowComments() )
 146+ if ( FlaggedRevs::allowComments() ) {
153147 $pars['notes'] = null;
154 - if ( FlaggedRevs::dimensionsEmpty() ) {
155 - $pars['unapprove'] = false;
156 - } else {
 148+ }
 149+ if ( !FlaggedRevs::binaryFlagging() ) {
157150 foreach ( FlaggedRevs::getDimensions() as $flagname => $levels ) {
158151 $pars['flag_' . $flagname] = array(
159152 ApiBase::PARAM_DFLT => 1, // default
@@ -165,15 +158,15 @@
166159
167160 public function getParamDescription() {
168161 $desc = array(
169 - 'revid' => 'The revision ID for which to set the flags',
170 - 'token' => 'An edit token retrieved through prop=info',
171 - 'comment' => 'Comment for the review (optional)'
 162+ 'revid' => 'The revision ID for which to set the flags',
 163+ 'token' => 'An edit token retrieved through prop=info',
 164+ 'comment' => 'Comment for the review (optional)',
 165+ 'unapprove' => 'If set, revision will be unapproved rather than approved.'
172166 );
173 - if ( FlaggedRevs::allowComments() )
 167+ if ( FlaggedRevs::allowComments() ) {
174168 $desc['notes'] = "Additional notes for the review. The ''validate'' right is needed to set this parameter.";
175 - if ( FlaggedRevs::dimensionsEmpty() ) {
176 - $desc['unapprove'] = "If set, revision will be unapproved rather than approved.";
177 - } else {
 169+ }
 170+ if ( !FlaggedRevs::binaryFlagging() ) {
178171 foreach ( FlaggedRevs::getTags() as $flagname ) {
179172 $desc['flag_' . $flagname] = "Set the flag ''{$flagname}'' to the specified value";
180173 }
@@ -189,11 +182,10 @@
190183 return array_merge( parent::getPossibleErrors(), array(
191184 array( 'badaccess-group0' ),
192185 array( 'blockedtext' ),
193 - array( 'code' => 'notarget', 'info' => 'Provided revision or page can not be reviewed.' ),
194 - array( 'code' => 'notreviewable', 'info' => 'Provided revision or page can not be reviewed.' ),
195 - array( 'code' => 'mixedapproval', 'info' => 'Either all or none of the flags have to be set to zero.' ),
196 - array( 'code' => 'permissiondenied', 'info' => 'You don\'t have the necessary rights to set the specified flags.' ),
197 - array( 'code' => 'syncfailure', 'info' => 'A sync failure has occured while reviewing. Please try again.' ),
 186+ array( 'code' => 'notarget', 'info' => 'Provided revision or page can not be found.' ),
 187+ array( 'code' => 'notreviewable', 'info' => 'Provided page is not reviewable.' ),
 188+ array( 'code' => 'mixedapproval', 'info' => 'No flags can be set to zero when accepting a revision.' ),
 189+ array( 'code' => 'permissiondenied', 'info' => 'Insufficient rights to set the specified flags.' ),
198190 ) );
199191 }
200192
Property changes on: branches/wmf/1.16wmf4/extensions/FlaggedRevs/FlaggedArticleView.php
___________________________________________________________________
Modified: svn:mergeinfo
201193 Merged /trunk/extensions/FlaggedRevs/FlaggedArticleView.php:r77276
Property changes on: branches/wmf/1.16wmf4/extensions/FlaggedRevs
___________________________________________________________________
Modified: svn:mergeinfo
202194 Merged /trunk/extensions/FlaggedRevs:r77276

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r77276Fixed a bunch of outdated api review code. In particular, setApprove/setUnapp...aaron10:46, 25 November 2010

Status & tagging log