r50996 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50995‎ | r50996 | r50997 >
Date:00:24, 26 May 2009
Author:aaron
Status:ok
Tags:
Comment:
Replace some hard-coded integers with constants
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -38,6 +38,7 @@
3939 if( !defined('FLAGGED_VIS_PRISTINE') )
4040 define('FLAGGED_VIS_PRISTINE',2);
4141
 42+# SELECT parameters...
4243 if( !defined('FR_FOR_UPDATE') )
4344 define('FR_FOR_UPDATE',1);
4445 if( !defined('FR_MASTER') )
@@ -45,6 +46,14 @@
4647 if( !defined('FR_TEXT') )
4748 define('FR_TEXT',3);
4849
 50+# Level constants...
 51+if( !defined('FR_SIGHTED') )
 52+ define('FR_SIGHTED',0);
 53+if( !defined('FR_QUALITY') )
 54+ define('FR_QUALITY',1);
 55+if( !defined('FR_PRISTINE') )
 56+ define('FR_PRISTINE',2);
 57+
4958 # Number of recent reviews to be a decent sample size
5059 if( !defined('READER_FEEDBACK_SIZE') )
5160 define('READER_FEEDBACK_SIZE',15);
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -275,10 +275,10 @@
276276 $config = $wgFlaggedRevsPrecedence;
277277 switch( $config )
278278 {
279 - case 2:
 279+ case FR_PRISTINE:
280280 $select = FLAGGED_VIS_PRISTINE;
281281 break;
282 - case 1:
 282+ case FR_QUALITY:
283283 $select = FLAGGED_VIS_QUALITY;
284284 break;
285285 default:
@@ -340,9 +340,9 @@
341341 public static function quickTags( $tier ) {
342342 switch( $tier )
343343 {
344 - case 2:
 344+ case FR_PRISTINE:
345345 return self::quickPristineTags();
346 - case 1:
 346+ case FR_QUALITY:
347347 return self::quickQualityTags();
348348 default:
349349 return self::quickSightedTags();
@@ -360,7 +360,7 @@
361361 # Find the maximum auto-review quality level
362362 $qal = min($wgFlaggedRevsAutoReview-1,$quality);
363363 # Pristine auto-review?
364 - if( $qal == 2 ) {
 364+ if( $qal == FR_PRISTINE ) {
365365 $flags = self::quickPristineTags();
366366 # If tags are available and user can set them, we are done...
367367 if( RevisionReview::userCanSetFlags( $flags, array(), $config ) ) {
@@ -369,7 +369,7 @@
370370 $qal--;
371371 }
372372 # Quality auto-review?
373 - if( $qal == 1 ) {
 373+ if( $qal == FR_QUALITY ) {
374374 $flags = self::quickQualityTags();
375375 # If tags are available and user can set them, we are done...
376376 if( RevisionReview::userCanSetFlags( $flags, array(), $config ) ) {
@@ -378,7 +378,7 @@
379379 $qal--;
380380 }
381381 # Sighted auto-review?
382 - if( $qal == 0 ) {
 382+ if( $qal == FR_SIGHTED ) {
383383 $flags = self::quickSightedTags();
384384 # If tags are available and user can set them, we are done...
385385 if( RevisionReview::userCanSetFlags( $flags, array(), $config ) ) {
@@ -837,8 +837,9 @@
838838 */
839839 public static function updatePendingList( $article, $latest = NULL ) {
840840 $data = array();
841 - $level = self::pristineVersions() ? 2 : 1;
842 - if( !self::qualityVersions() ) $level--;
 841+ $level = self::pristineVersions() ? FR_PRISTINE : FR_QUALITY;
 842+ if( !self::qualityVersions() )
 843+ $level = FR_SIGHTED;
843844 # Get the latest revision ID
844845 $lastID = $latest ? $latest : $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
845846 $pageId = $article->getId();
@@ -1089,9 +1090,9 @@
10901091 */
10911092 public static function getLevelTier( $flags ) {
10921093 if( self::isPristine($flags ) )
1093 - return 2;
 1094+ return FR_PRISTINE;
10941095 else if( self::isQuality($flags ) )
1095 - return 1;
 1096+ return FR_QUALITY;
10961097 else
10971098 return 0;
10981099 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -146,7 +146,7 @@
147147 $prow = $dbw->selectRow( array('flaggedrevs','revision'),
148148 $columns,
149149 array( 'fr_page_id' => $pageId,
150 - 'fr_quality = 2',
 150+ 'fr_quality = '.FR_PRISTINE,
151151 'rev_id = fr_rev_id',
152152 'rev_page = fr_page_id',
153153 'rev_deleted & '.Revision::DELETED_TEXT => 0
@@ -166,7 +166,7 @@
167167 $qrow = $dbw->selectRow( array('flaggedrevs','revision'),
168168 $columns,
169169 array( 'fr_page_id' => $pageId,
170 - 'fr_quality = 1',
 170+ 'fr_quality = '.FR_QUALITY,
171171 $newerClause,
172172 'rev_id = fr_rev_id',
173173 'rev_page = fr_page_id',

Status & tagging log