r35126 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35125‎ | r35126 | r35127 >
Date:01:56, 21 May 2008
Author:tstarling
Status:old
Tags:
Comment:
* Fixed some minor schema issues
* Made some style changes in updateAutoPromote.php/inc
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.sql (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/updateAutoPromote.inc (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/updateAutoPromote.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/maintenance/updateAutoPromote.php
@@ -1,10 +1,12 @@
22 <?php
33
4 -# Assume normal setup...
5 -require dirname(__FILE__) . '/../../../maintenance/commandLine.inc';
 4+if ( getenv( 'MW_INSTALL_PATH' ) ) {
 5+ $IP = getenv( 'MW_INSTALL_PATH' );
 6+} else {
 7+ $IP = dirname(__FILE__).'/../..';
 8+}
 9+require "$IP/maintenance/commandLine.inc";
610 require dirname(__FILE__) . '/updateAutoPromote.inc';
711
8 -error_reporting( E_ALL );
9 -
1012 update_autopromote();
1113
Index: trunk/extensions/FlaggedRevs/maintenance/updateAutoPromote.inc
@@ -1,29 +1,25 @@
22 <?php
33
 4+
45 function update_autopromote() {
56 global $wgContentNamespaces, $wgFlaggedRevsAutopromote;
6 - echo "Populating and updating autopromote table\n";
7 -
8 - $BATCH_SIZE = 25;
9 -
 7+ $batchSize = 25;
 8+ echo "Populating and updating flaggedrevs_promote table\n";
 9+
1010 $db = wfGetDB( DB_SLAVE );
11 -
1211 $start = $db->selectField( 'user', 'MIN(user_id)', false, __FUNCTION__ );
1312 $end = $db->selectField( 'user', 'MAX(user_id)', false, __FUNCTION__ );
1413 if( is_null( $start ) || is_null( $end ) ){
1514 echo "...user table seems to be empty.\n";
1615 return;
1716 }
18 - # Do remaining chunk
19 - $end += $BATCH_SIZE - 1;
20 - $blockStart = $start;
21 - $blockEnd = $start + $BATCH_SIZE - 1;
2217 $count = 0;
2318 $changed = 0;
24 - while( $blockEnd <= $end ) {
 19+ for ( $blockStart = $start; $blockStart <= $end; $blockStart += $batchSize ) {
 20+ $blockEnd = min( $end, $blockStart + $batchSize - 1 );
2521 echo "...doing user_id from $blockStart to $blockEnd\n";
2622 $cond = "user_id BETWEEN $blockStart AND $blockEnd\n";
27 - $res = $db->select( array('user'), '*', $cond, __FUNCTION__ );
 23+ $res = $db->select( 'user', '*', $cond, __FUNCTION__ );
2824 # Go through and clean up missing items, as well as correct fr_quality...
2925 foreach( $res as $row ) {
3026 $user = User::newFromRow( $row );
@@ -37,7 +33,6 @@
3834 array( 'LIMIT' => $wgFlaggedRevsAutopromote['editComments'] )
3935 );
4036 $p['editComments'] = $db->numRows( $sres );
41 - $db->freeResult( $sres );
4237 # Get content page edits
4338 $sres = $db->select( array('revision','page'), '1',
4439 array( 'rev_user' => $user->getID(),
@@ -47,7 +42,6 @@
4843 array( 'LIMIT' => $wgFlaggedRevsAutopromote['totalContentEdits'] )
4944 );
5045 $p['totalContentEdits'] = $db->numRows( $sres );
51 - $db->freeResult( $sres );
5246 # Get unique content pages edited
5347 $sres = $db->select( array('revision','page'), 'DISTINCT (rev_page)',
5448 array( 'rev_user' => $user->getID(),
@@ -57,18 +51,15 @@
5852 array( 'LIMIT' => $wgFlaggedRevsAutopromote['uniqueContentPages'] )
5953 );
6054 $p['uniqueContentPages'] = $db->numRows( $sres );
61 - $db->freeResult( $sres );
6255
63 - FlaggedRevs::saveUserParams( $user, $p );
64 - if( $oldp != $p )
 56+ if( $oldp != $p ) {
 57+ FlaggedRevs::saveUserParams( $user, $p );
6558 $changed++;
 59+ }
6660
6761 $count++;
6862 }
69 - $db->freeResult( $res );
70 - $blockStart += $BATCH_SIZE - 1;
71 - $blockEnd += $BATCH_SIZE - 1;
7263 wfWaitForSlaves( 5 );
7364 }
74 - echo "autopromote table update complete ... {$count} rows [{$changed} changed or added]\n";
 65+ echo "flaggedrevs_promote table update complete ... {$count} rows [{$changed} changed or added]\n";
7566 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.sql
@@ -17,7 +17,7 @@
1818 PRIMARY KEY (fp_page_id),
1919 INDEX fp_reviewed_page (fp_reviewed,fp_page_id),
2020 INDEX fp_quality_page (fp_quality,fp_page_id)
21 -) TYPE=InnoDB;
 21+) /*$wgDBTableOptions*/;
2222
2323 -- This stores all of our rev reviews
2424 CREATE TABLE /*$wgDBprefix*/flaggedrevs (
@@ -28,15 +28,15 @@
2929 -- Foreign key to user.user_id
3030 fr_user int(5) NOT NULL,
3131 fr_timestamp char(14) NOT NULL,
32 - fr_comment mediumblob NOT NULL default '',
 32+ fr_comment mediumblob NOT NULL,
3333 -- Store the precedence level
3434 fr_quality tinyint(1) NOT NULL default 0,
3535 -- Store tag metadata as newline separated,
3636 -- colon separated tag:value pairs
37 - fr_tags mediumblob NOT NULL default '',
 37+ fr_tags mediumblob NOT NULL,
3838 -- Store the text with all transclusions resolved
3939 -- This will trade space for speed
40 - fr_text mediumblob NOT NULL default '',
 40+ fr_text mediumblob NOT NULL,
4141 -- Comma-separated list of flags:
4242 -- gzip: text is compressed with PHP's gzdeflate() function.
4343 -- utf8: in UTF-8
@@ -53,7 +53,7 @@
5454 PRIMARY KEY (fr_page_id,fr_rev_id),
5555 INDEX fr_img_sha1 (fr_img_sha1),
5656 INDEX page_qal_rev (fr_page_id,fr_quality,fr_rev_id)
57 -) TYPE=InnoDB;
 57+) /*$wgDBTableOptions*/;
5858
5959 -- This stores settings on how to select the default revision
6060 CREATE TABLE /*$wgDBprefix*/flaggedpage_config (
@@ -69,7 +69,7 @@
7070
7171 PRIMARY KEY (fpc_page_id),
7272 INDEX (fpc_expiry)
73 -) TYPE=InnoDB;
 73+) /*$wgDBTableOptions*/;
7474
7575 -- This stores all of our transclusion revision pointers
7676 CREATE TABLE /*$wgDBprefix*/flaggedtemplates (
@@ -81,7 +81,7 @@
8282 ft_tmp_rev_id integer NULL,
8383
8484 PRIMARY KEY (ft_rev_id,ft_namespace,ft_title)
85 -) TYPE=InnoDB;
 85+) /*$wgDBTableOptions*/;
8686
8787 -- This stores all of our image revision pointers
8888 CREATE TABLE /*$wgDBprefix*/flaggedimages (
@@ -94,13 +94,13 @@
9595 fi_img_sha1 varbinary(32) NOT NULL default '',
9696
9797 PRIMARY KEY (fi_rev_id,fi_name)
98 -) TYPE=InnoDB;
 98+) /*$wgDBTableOptions*/;
9999
100100 -- This stores user demotions and stats
101101 CREATE TABLE /*$wgDBprefix*/flaggedrevs_promote (
102102 -- Foreign key to user.user_id
103103 frp_user_id integer NOT NULL,
104 - frp_user_params mediumblob NOT NULL default '',
 104+ frp_user_params mediumblob NOT NULL,
105105
106106 PRIMARY KEY (frp_user_id)
107 -) TYPE=InnoDB;
 107+) /*$wgDBTableOptions*/;

Status & tagging log