r45382 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45381‎ | r45382 | r45383 >
Date:21:12, 3 January 2009
Author:aaron
Status:deferred
Tags:
Comment:
* Track # of reviewed edits for users
* Some minor cleanup
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/maintenance/updateAutoPromote.inc (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -200,6 +200,7 @@
201201 'benchmarks' => 15, # how many edit intervals are needed?
202202 'recentContentEdits' => 10, # $wgContentNamespaces edits in recent changes
203203 'totalContentEdits' => 300, # $wgContentNamespaces edits
 204+ 'reviewedEdits' => 200, # Sighted edits (not used yet)
204205 'uniqueContentPages' => 10, # $wgContentNamespaces unique pages edited
205206 'editComments' => 50, # how many edit comments used?
206207 'email' => false, # user must be emailconfirmed?
Index: trunk/extensions/FlaggedRevs/maintenance/updateAutoPromote.inc
@@ -43,7 +43,7 @@
4444 );
4545 $p['totalContentEdits'] = $db->numRows( $sres );
4646 # Get unique content pages edited
47 - $sres = $db->select( array('revision','page'), 'DISTINCT (rev_page)',
 47+ $sres = $db->select( array('revision','page'), 'DISTINCT(rev_page)',
4848 array( 'rev_user' => $user->getID(),
4949 'page_id = rev_page',
5050 'page_namespace' => $wgContentNamespaces ),
@@ -51,6 +51,15 @@
5252 array( 'LIMIT' => $wgFlaggedRevsAutopromote['uniqueContentPages'] )
5353 );
5454 $p['uniqueContentPages'] = $db->numRows( $sres );
 55+ # Get reviewed edits
 56+ $sres = $db->select( array('revision','flaggedrevs'), '1',
 57+ array( 'rev_user' => $user->getID(),
 58+ 'fr_page_id = rev_page',
 59+ 'fr_rev_id = rev_id' ),
 60+ __METHOD__,
 61+ array( 'LIMIT' => $wgFlaggedRevsAutopromote['reviewedEdits'] )
 62+ );
 63+ $p['reviewedEdits'] = $db->numRows( $sres );
5564
5665 if( $oldp != $p ) {
5766 FlaggedRevs::saveUserParams( $user, $p );
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -887,12 +887,12 @@
888888
889889 /**
890890 * Get params for a user
891 - * @param User $user
 891+ * @param int $uid
892892 */
893 - public static function getUserParams( $user ) {
 893+ public static function getUserParams( $uid ) {
894894 $dbw = wfGetDB( DB_MASTER );
895895 $row = $dbw->selectRow( 'flaggedrevs_promote', 'frp_user_params',
896 - array( 'frp_user_id' => $user->getId() ),
 896+ array( 'frp_user_id' => $uid ),
897897 __METHOD__ );
898898 # Parse params
899899 $params = array();
@@ -910,10 +910,10 @@
911911
912912 /**
913913 * Save params for a user
914 - * @param User $user
 914+ * @param int $uid
915915 * @param Array $params
916916 */
917 - public static function saveUserParams( $user, $params ) {
 917+ public static function saveUserParams( $uid, $params ) {
918918 $flatParams = '';
919919 foreach( $params as $key => $value ) {
920920 $flatParams .= "{$key}={$value}\n";
@@ -921,10 +921,9 @@
922922 $dbw = wfGetDB( DB_MASTER );
923923 $row = $dbw->replace( 'flaggedrevs_promote',
924924 array( 'frp_user_id' ),
925 - array( 'frp_user_id' => $user->getId(),
926 - 'frp_user_params' => trim($flatParams) ),
927 - __METHOD__ );
928 -
 925+ array( 'frp_user_id' => $uid, 'frp_user_params' => trim($flatParams) ),
 926+ __METHOD__
 927+ );
929928 return ( $dbw->affectedRows() > 0 );
930929 }
931930
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php
@@ -656,6 +656,16 @@
657657 }
658658 # Update link tracking. This will trigger our hook to add stable links too...
659659 $u->doUpdate();
 660+
 661+ # Update user stats if this rev was not flagged
 662+ if( !$oldfrev && $rev->getRawUser() ) {
 663+ global $wgFlaggedRevsAutopromote;
 664+ $p = FlaggedRevs::getUserParams( $rev->getRawUser() );
 665+ $p['reviewedEdits'] = isset($p['reviewedEdits']) ? $p['reviewedEdits'] : 0;
 666+ $p['reviewedEdits']++;
 667+ if( $wgFlaggedRevsAutopromote['reviewedEdits'] > $p['reviewedEdits'] )
 668+ FlaggedRevs::saveUserParams( $rev->getRawUser(), $p );
 669+ }
660670
661671 $dbw->commit();
662672 # Purge cache/squids for this page and any page that uses it
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -790,12 +790,12 @@
791791 # Grab current groups
792792 $groups = $user->getGroups();
793793 # Do not give this to current holders or bots
794 - if( $user->isAllowed('bot') || in_array('bot',$groups) || in_array('editor',$groups) ) {
 794+ if( $user->isAllowed('bot') || in_array('editor',$groups) ) {
795795 wfProfileOut( __METHOD__ );
796796 return true;
797797 }
798798 # Do not re-add status if it was previously removed!
799 - $p = FlaggedRevs::getUserParams( $user );
 799+ $p = FlaggedRevs::getUserParams( $user->getId() );
800800 if( isset($p['demoted']) && $p['demoted'] ) {
801801 wfProfileOut( __METHOD__ );
802802 return true;
@@ -806,6 +806,7 @@
807807 $p['uniqueContentPages'] = isset($p['uniqueContentPages']) ? $p['uniqueContentPages'] : '';
808808 $p['totalContentEdits'] = isset($p['totalContentEdits']) ? $p['totalContentEdits'] : 0;
809809 $p['editComments'] = isset($p['editComments']) ? $p['editComments'] : 0;
 810+ $p['reviewedEdits'] = isset($p['reviewedEdits']) ? $p['reviewedEdits'] : 0;
810811 if( $article->getTitle()->isContentPage() ) {
811812 $pages = explode( ',', trim($p['uniqueContentPages']) ); // page IDs
812813 # Don't let this get bloated for no reason
@@ -822,7 +823,7 @@
823824 }
824825 # Save any updates to user params
825826 if( $changed ) {
826 - FlaggedRevs::saveUserParams( $user, $p );
 827+ FlaggedRevs::saveUserParams( $user->getId(), $p );
827828 }
828829 # Check if user edited enough content pages
829830 if( $wgFlaggedRevsAutopromote['totalContentEdits'] > $p['totalContentEdits'] ) {
@@ -1022,9 +1023,9 @@
10231024 */
10241025 public static function recordDemote( $u, $addgroup, $removegroup ) {
10251026 if( $removegroup && in_array('editor',$removegroup) ) {
1026 - $params = FlaggedRevs::getUserParams( $u );
 1027+ $params = FlaggedRevs::getUserParams( $u->getId() );
10271028 $params['demoted'] = 1;
1028 - FlaggedRevs::saveUserParams( $u, $params );
 1029+ FlaggedRevs::saveUserParams( $u->getId(), $params );
10291030 }
10301031 return true;
10311032 }

Status & tagging log