Index: trunk/extensions/FlaggedRevs/maintenance/updateAutoPromote.php |
— | — | @@ -1,10 +1,12 @@ |
2 | 2 | <?php |
3 | 3 | |
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"; |
6 | 10 | require dirname(__FILE__) . '/updateAutoPromote.inc'; |
7 | 11 | |
8 | | -error_reporting( E_ALL ); |
9 | | - |
10 | 12 | update_autopromote(); |
11 | 13 | |
Index: trunk/extensions/FlaggedRevs/maintenance/updateAutoPromote.inc |
— | — | @@ -1,29 +1,25 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | + |
4 | 5 | function update_autopromote() { |
5 | 6 | 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 | + |
10 | 10 | $db = wfGetDB( DB_SLAVE ); |
11 | | - |
12 | 11 | $start = $db->selectField( 'user', 'MIN(user_id)', false, __FUNCTION__ ); |
13 | 12 | $end = $db->selectField( 'user', 'MAX(user_id)', false, __FUNCTION__ ); |
14 | 13 | if( is_null( $start ) || is_null( $end ) ){ |
15 | 14 | echo "...user table seems to be empty.\n"; |
16 | 15 | return; |
17 | 16 | } |
18 | | - # Do remaining chunk |
19 | | - $end += $BATCH_SIZE - 1; |
20 | | - $blockStart = $start; |
21 | | - $blockEnd = $start + $BATCH_SIZE - 1; |
22 | 17 | $count = 0; |
23 | 18 | $changed = 0; |
24 | | - while( $blockEnd <= $end ) { |
| 19 | + for ( $blockStart = $start; $blockStart <= $end; $blockStart += $batchSize ) { |
| 20 | + $blockEnd = min( $end, $blockStart + $batchSize - 1 ); |
25 | 21 | echo "...doing user_id from $blockStart to $blockEnd\n"; |
26 | 22 | $cond = "user_id BETWEEN $blockStart AND $blockEnd\n"; |
27 | | - $res = $db->select( array('user'), '*', $cond, __FUNCTION__ ); |
| 23 | + $res = $db->select( 'user', '*', $cond, __FUNCTION__ ); |
28 | 24 | # Go through and clean up missing items, as well as correct fr_quality... |
29 | 25 | foreach( $res as $row ) { |
30 | 26 | $user = User::newFromRow( $row ); |
— | — | @@ -37,7 +33,6 @@ |
38 | 34 | array( 'LIMIT' => $wgFlaggedRevsAutopromote['editComments'] ) |
39 | 35 | ); |
40 | 36 | $p['editComments'] = $db->numRows( $sres ); |
41 | | - $db->freeResult( $sres ); |
42 | 37 | # Get content page edits |
43 | 38 | $sres = $db->select( array('revision','page'), '1', |
44 | 39 | array( 'rev_user' => $user->getID(), |
— | — | @@ -47,7 +42,6 @@ |
48 | 43 | array( 'LIMIT' => $wgFlaggedRevsAutopromote['totalContentEdits'] ) |
49 | 44 | ); |
50 | 45 | $p['totalContentEdits'] = $db->numRows( $sres ); |
51 | | - $db->freeResult( $sres ); |
52 | 46 | # Get unique content pages edited |
53 | 47 | $sres = $db->select( array('revision','page'), 'DISTINCT (rev_page)', |
54 | 48 | array( 'rev_user' => $user->getID(), |
— | — | @@ -57,18 +51,15 @@ |
58 | 52 | array( 'LIMIT' => $wgFlaggedRevsAutopromote['uniqueContentPages'] ) |
59 | 53 | ); |
60 | 54 | $p['uniqueContentPages'] = $db->numRows( $sres ); |
61 | | - $db->freeResult( $sres ); |
62 | 55 | |
63 | | - FlaggedRevs::saveUserParams( $user, $p ); |
64 | | - if( $oldp != $p ) |
| 56 | + if( $oldp != $p ) { |
| 57 | + FlaggedRevs::saveUserParams( $user, $p ); |
65 | 58 | $changed++; |
| 59 | + } |
66 | 60 | |
67 | 61 | $count++; |
68 | 62 | } |
69 | | - $db->freeResult( $res ); |
70 | | - $blockStart += $BATCH_SIZE - 1; |
71 | | - $blockEnd += $BATCH_SIZE - 1; |
72 | 63 | wfWaitForSlaves( 5 ); |
73 | 64 | } |
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"; |
75 | 66 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.sql |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | PRIMARY KEY (fp_page_id), |
19 | 19 | INDEX fp_reviewed_page (fp_reviewed,fp_page_id), |
20 | 20 | INDEX fp_quality_page (fp_quality,fp_page_id) |
21 | | -) TYPE=InnoDB; |
| 21 | +) /*$wgDBTableOptions*/; |
22 | 22 | |
23 | 23 | -- This stores all of our rev reviews |
24 | 24 | CREATE TABLE /*$wgDBprefix*/flaggedrevs ( |
— | — | @@ -28,15 +28,15 @@ |
29 | 29 | -- Foreign key to user.user_id |
30 | 30 | fr_user int(5) NOT NULL, |
31 | 31 | fr_timestamp char(14) NOT NULL, |
32 | | - fr_comment mediumblob NOT NULL default '', |
| 32 | + fr_comment mediumblob NOT NULL, |
33 | 33 | -- Store the precedence level |
34 | 34 | fr_quality tinyint(1) NOT NULL default 0, |
35 | 35 | -- Store tag metadata as newline separated, |
36 | 36 | -- colon separated tag:value pairs |
37 | | - fr_tags mediumblob NOT NULL default '', |
| 37 | + fr_tags mediumblob NOT NULL, |
38 | 38 | -- Store the text with all transclusions resolved |
39 | 39 | -- This will trade space for speed |
40 | | - fr_text mediumblob NOT NULL default '', |
| 40 | + fr_text mediumblob NOT NULL, |
41 | 41 | -- Comma-separated list of flags: |
42 | 42 | -- gzip: text is compressed with PHP's gzdeflate() function. |
43 | 43 | -- utf8: in UTF-8 |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | PRIMARY KEY (fr_page_id,fr_rev_id), |
55 | 55 | INDEX fr_img_sha1 (fr_img_sha1), |
56 | 56 | INDEX page_qal_rev (fr_page_id,fr_quality,fr_rev_id) |
57 | | -) TYPE=InnoDB; |
| 57 | +) /*$wgDBTableOptions*/; |
58 | 58 | |
59 | 59 | -- This stores settings on how to select the default revision |
60 | 60 | CREATE TABLE /*$wgDBprefix*/flaggedpage_config ( |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | |
71 | 71 | PRIMARY KEY (fpc_page_id), |
72 | 72 | INDEX (fpc_expiry) |
73 | | -) TYPE=InnoDB; |
| 73 | +) /*$wgDBTableOptions*/; |
74 | 74 | |
75 | 75 | -- This stores all of our transclusion revision pointers |
76 | 76 | CREATE TABLE /*$wgDBprefix*/flaggedtemplates ( |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | ft_tmp_rev_id integer NULL, |
83 | 83 | |
84 | 84 | PRIMARY KEY (ft_rev_id,ft_namespace,ft_title) |
85 | | -) TYPE=InnoDB; |
| 85 | +) /*$wgDBTableOptions*/; |
86 | 86 | |
87 | 87 | -- This stores all of our image revision pointers |
88 | 88 | CREATE TABLE /*$wgDBprefix*/flaggedimages ( |
— | — | @@ -94,13 +94,13 @@ |
95 | 95 | fi_img_sha1 varbinary(32) NOT NULL default '', |
96 | 96 | |
97 | 97 | PRIMARY KEY (fi_rev_id,fi_name) |
98 | | -) TYPE=InnoDB; |
| 98 | +) /*$wgDBTableOptions*/; |
99 | 99 | |
100 | 100 | -- This stores user demotions and stats |
101 | 101 | CREATE TABLE /*$wgDBprefix*/flaggedrevs_promote ( |
102 | 102 | -- Foreign key to user.user_id |
103 | 103 | frp_user_id integer NOT NULL, |
104 | | - frp_user_params mediumblob NOT NULL default '', |
| 104 | + frp_user_params mediumblob NOT NULL, |
105 | 105 | |
106 | 106 | PRIMARY KEY (frp_user_id) |
107 | | -) TYPE=InnoDB; |
| 107 | +) /*$wgDBTableOptions*/; |