r84170 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84169‎ | r84170 | r84171 >
Date:15:20, 17 March 2011
Author:aaron
Status:resolved
Tags:
Comment:
* Combined $wgFlaggedRevsAutoReview/$wgFlaggedRevsAutoReviewNew into just $wgFlaggedRevsAutoReview, with b/c
* Autoreviewing of new pages but not edits to existing ones is now an allowed setting (though not that useful)
* Moved defined constants to their own file
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsDefines.php (added) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -28,30 +28,6 @@
2929 return;
3030 }
3131
32 -# SELECT parameters...
33 -if ( !defined( 'FR_FOR_UPDATE' ) )
34 - define( 'FR_FOR_UPDATE', 1 );
35 -if ( !defined( 'FR_MASTER' ) )
36 - define( 'FR_MASTER', 2 );
37 -if ( !defined( 'FR_TEXT' ) )
38 - define( 'FR_TEXT', 3 );
39 -
40 -# Level constants...
41 -if ( !defined( 'FR_CHECKED' ) )
42 - define( 'FR_CHECKED', 0 ); // "basic"/"checked"
43 -if ( !defined( 'FR_QUALITY' ) )
44 - define( 'FR_QUALITY', 1 );
45 -if ( !defined( 'FR_PRISTINE' ) )
46 - define( 'FR_PRISTINE', 2 );
47 -
48 -# Include settings
49 -if ( !defined( 'FR_INCLUDES_CURRENT' ) )
50 - define( 'FR_INCLUDES_CURRENT', 0 );
51 -if ( !defined( 'FR_INCLUDES_FREEZE' ) )
52 - define( 'FR_INCLUDES_FREEZE', 1 );
53 -if ( !defined( 'FR_INCLUDES_STABLE' ) )
54 - define( 'FR_INCLUDES_STABLE', 2 );
55 -
5632 $wgExtensionCredits['specialpage'][] = array(
5733 'path' => __FILE__,
5834 'name' => 'Flagged Revisions',
@@ -60,6 +36,9 @@
6137 'descriptionmsg' => 'flaggedrevs-desc',
6238 );
6339
 40+# Load global constants
 41+include_once( "FlaggedRevsDefines.php" );
 42+
6443 # ######## Configuration variables ########
6544 # IMPORTANT: DO NOT EDIT THIS FILE
6645 # When configuring globals, set them at LocalSettings.php instead
@@ -87,12 +66,19 @@
8867 # Can users make comments that will show up below flagged revisions?
8968 # NOTE: this is NOT the same as the simple log comment
9069 $wgFlaggedRevsComments = false; // @TODO: remove when ready?
91 -# Auto-review edits that are:
92 -# (a) directly to the stable version by users with 'autoreview'/'bot'
93 -# (b) self-reversions back to the stable version by any user
94 -$wgFlaggedRevsAutoReview = true;
95 -# If $wgFlaggedRevsAutoReview, auto-review new pages as minimally "checked"?
96 -$wgFlaggedRevsAutoReviewNew = true;
 70+# Auto-review settings for edits/new pages:
 71+# FR_AUTOREVIEW_NONE
 72+# Don't auto-review any edits or new pages
 73+# FR_AUTOREVIEW_CHANGES
 74+# Auto-review the following types of edits (to existing pages):
 75+# (a) changes directly to the stable version by users with 'autoreview'/'bot'
 76+# (b) reversions to old reviewed versions by users with 'autoreview'/'bot'
 77+# (c) self-reversions back to the stable version by any user
 78+# FR_AUTOREVIEW_CREATION
 79+# Auto-review new pages as minimally "checked"
 80+# FR_AUTOREVIEW_BOTH
 81+# Combines FR_AUTOREVIEW_CHANGES and FR_AUTOREVIEW_CREATION
 82+$wgFlaggedRevsAutoReview = FR_AUTOREVIEW_BOTH;
9783
9884 # Define the tags we can use to rate an article, number of levels,
9985 # and set the minimum level to have it become a "quality" or "pristine" version.
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -19,6 +19,8 @@
2020 protected static $patrolNamespaces = array();
2121 # Restriction levels/config
2222 protected static $restrictionLevels = array();
 23+ # Autoreview config
 24+ protected static $autoReviewConfig = 0;
2325
2426 protected static $loaded = false;
2527
@@ -108,10 +110,18 @@
109111 self::$reviewNamespaces = $wgFlaggedRevsNamespaces;
110112 # Note: reviewable *pages* override patrollable ones
111113 self::$patrolNamespaces = $wgFlaggedRevsPatrolNamespaces;
112 - # !$wgFlaggedRevsAutoReview => !$wgFlaggedRevsAutoReviewNew
 114+ # B/C for $wgFlaggedRevsAutoReview
113115 global $wgFlaggedRevsAutoReview, $wgFlaggedRevsAutoReviewNew;
114 - if ( !$wgFlaggedRevsAutoReview ) {
115 - $wgFlaggedRevsAutoReviewNew = false;
 116+ if ( is_int( $wgFlaggedRevsAutoReview ) ) {
 117+ self::$autoReviewConfig = $wgFlaggedRevsAutoReview;
 118+ } else {
 119+ if ( $wgFlaggedRevsAutoReview ) {
 120+ self::$autoReviewConfig |= FR_AUTOREVIEW_CHANGES; // b/c
 121+ }
 122+ if ( $wgFlaggedRevsAutoReviewNew ) {
 123+ self::$autoReviewConfig |= FR_AUTOREVIEW_CREATION; // b/c
 124+ }
 125+ wfWarn( '$wgFlaggedRevsAutoReview is now a bitfield instead of a boolean. $wgFlaggedRevsAutoReviewNew is deprecated.' );
116126 }
117127 }
118128
@@ -162,8 +172,8 @@
163173 * @returns bool
164174 */
165175 public static function autoReviewEdits() {
166 - global $wgFlaggedRevsAutoReview;
167 - return (bool)$wgFlaggedRevsAutoReview;
 176+ self::load();
 177+ return self::$autoReviewConfig & FR_AUTOREVIEW_CHANGES;
168178 }
169179
170180 /**
@@ -171,11 +181,19 @@
172182 * @returns bool
173183 */
174184 public static function autoReviewNewPages() {
175 - global $wgFlaggedRevsAutoReviewNew;
176 - return (bool)$wgFlaggedRevsAutoReviewNew;
 185+ self::load();
 186+ return self::$autoReviewConfig & FR_AUTOREVIEW_CREATION;
177187 }
178188
179189 /**
 190+ * Auto-review of new pages or edits to pages enabled?
 191+ * @returns bool
 192+ */
 193+ public static function autoReviewEnabled() {
 194+ return self::autoReviewEdits() || self::autoReviewNewPages();
 195+ }
 196+
 197+ /**
180198 * Get the maximum level that $tag can be autoreviewed to
181199 * @param string $tag
182200 * @returns int
@@ -183,8 +201,8 @@
184202 public static function maxAutoReviewLevel( $tag ) {
185203 global $wgFlaggedRevsTagsAuto;
186204 self::load();
187 - if ( !self::autoReviewEdits() ) {
188 - return 0; // no auto-review allowed at all
 205+ if ( !self::autoReviewEnabled() ) {
 206+ return 0; // shouldn't happen
189207 }
190208 if ( isset( $wgFlaggedRevsTagsAuto[$tag] ) ) {
191209 return (int)$wgFlaggedRevsTagsAuto[$tag];
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -618,7 +618,7 @@
619619 }
620620 }
621621 # All cases below require auto-review of edits to be enabled
622 - if ( !FlaggedRevs::autoReviewEdits() ) {
 622+ if ( !FlaggedRevs::autoReviewEnabled() ) {
623623 return true;
624624 }
625625 # If a $baseRevId is passed in, the edit is using an old revision's text
@@ -653,7 +653,9 @@
654654 } elseif ( $baseRevId ) {
655655 $reviewableNewPage = false; // had previous rev
656656 # Check if the base revision was reviewed...
657 - $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER );
 657+ if ( FlaggedRevs::autoReviewEdits() ) {
 658+ $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER );
 659+ }
658660 $reviewableChange = (bool)$frev;
659661 }
660662 // Is this an edit directly to a reviewed version or a new page?
Index: trunk/extensions/FlaggedRevs/FlaggedRevsDefines.php
@@ -0,0 +1,25 @@
 2+<?php
 3+/*
 4+* Defines global constants, some of which are used in LocalSettings.php
 5+*/
 6+
 7+# Query SELECT parameters...
 8+define( 'FR_FOR_UPDATE', 1 );
 9+define( 'FR_MASTER', 2 );
 10+define( 'FR_TEXT', 3 );
 11+
 12+# Review tier constants...
 13+define( 'FR_CHECKED', 0 ); // "basic"/"checked"
 14+define( 'FR_QUALITY', 1 );
 15+define( 'FR_PRISTINE', 2 );
 16+
 17+# Inclusion (templates/files) settings
 18+define( 'FR_INCLUDES_CURRENT', 0 );
 19+define( 'FR_INCLUDES_FREEZE', 1 );
 20+define( 'FR_INCLUDES_STABLE', 2 );
 21+
 22+# Autoreview settings for priviledged users
 23+define( 'FR_AUTOREVIEW_NONE', 0 );
 24+define( 'FR_AUTOREVIEW_CHANGES', 1 );
 25+define( 'FR_AUTOREVIEW_CREATION', 2 );
 26+define( 'FR_AUTOREVIEW_BOTH', FR_AUTOREVIEW_CHANGES | FR_AUTOREVIEW_CREATION );
Property changes on: trunk/extensions/FlaggedRevs/FlaggedRevsDefines.php
___________________________________________________________________
Added: svn:eol-style
127 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r84172Fixed silly bug in r84170aaron15:40, 17 March 2011
r84180Tweak r84170 for verbosity's sackaaron16:49, 17 March 2011
r84725* Fixed b/c in r84170 for $wgFlaggedRevsAutoreviewNew...aaron01:56, 25 March 2011

Status & tagging log