Index: trunk/extensions/FlaggedRevs/specialpages/OldReviewedPages_body.php |
— | — | @@ -286,9 +286,9 @@ |
287 | 287 | public $mForm, $mConds; |
288 | 288 | private $category, $namespace; |
289 | 289 | |
290 | | - function __construct( $form, $namespace, $level=-1, $category='', $size=NULL, |
291 | | - $watched=false, $stable=false ) |
292 | | - { |
| 290 | + function __construct( |
| 291 | + $form, $namespace, $level=-1, $category='', $size=NULL, $watched=false, $stable=false |
| 292 | + ) { |
293 | 293 | $this->mForm = $form; |
294 | 294 | # Must be a content page... |
295 | 295 | global $wgFlaggedRevsNamespaces; |
— | — | @@ -305,7 +305,7 @@ |
306 | 306 | # Sanity check level: 0 = sighted; 1 = quality; 2 = pristine |
307 | 307 | $this->level = ($level >= 0 && $level <= 2) ? $level : -1; |
308 | 308 | $this->category = $category ? str_replace(' ','_',$category) : NULL; |
309 | | - $this->size = $size ? $size : NULL; |
| 309 | + $this->size = ($size !== null) ? intval($size) : NULL; |
310 | 310 | $this->watched = (bool)$watched; |
311 | 311 | $this->stable = $stable && !FlaggedRevs::showStableByDefault(); |
312 | 312 | parent::__construct(); |
— | — | @@ -400,7 +400,10 @@ |
401 | 401 | } |
402 | 402 | # Filter by bytes changed |
403 | 403 | if( $this->size !== null && $this->size >= 0 ) { |
404 | | - $conds[] = 'ABS(page_len - rev_len) <= '.intval($this->size); |
| 404 | + # Get absolute difference for comparison. ABS(x-y) |
| 405 | + # is broken due to mysql unsigned int design. |
| 406 | + $conds[] = 'GREATEST(page_len,rev_len)-LEAST(page_len,rev_len) <= '. |
| 407 | + intval($this->size); |
405 | 408 | } |
406 | 409 | return array( |
407 | 410 | 'tables' => $tables, |
Index: trunk/extensions/FlaggedRevs/api/ApiQueryOldreviewedpages.php |
— | — | @@ -44,12 +44,17 @@ |
45 | 45 | $params = $this->extractRequestParams(); |
46 | 46 | |
47 | 47 | // Construct SQL Query |
48 | | - $this->addTables( array( 'page', 'flaggedpages' ) ); |
| 48 | + $this->addTables( array( 'page', 'flaggedpages', 'revision' ) ); |
49 | 49 | $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
50 | 50 | if( $params['filterredir'] == 'redirects' ) |
51 | 51 | $this->addWhereFld( 'page_is_redirect', 1 ); |
52 | 52 | if( $params['filterredir'] == 'nonredirects' ) |
53 | 53 | $this->addWhereFld( 'page_is_redirect', 0 ); |
| 54 | + if( $params['maxsize'] !== null ) |
| 55 | + # Get absolute difference for comparison. ABS(x-y) |
| 56 | + # is broken due to mysql unsigned int design. |
| 57 | + $this->addWhere( 'GREATEST(page_len,rev_len)-LEAST(page_len,rev_len) <= '. |
| 58 | + intval($params['maxsize']) ); |
54 | 59 | $this->addWhereRange( |
55 | 60 | 'fp_pending_since', |
56 | 61 | $params['dir'], |
— | — | @@ -57,8 +62,10 @@ |
58 | 63 | $params['end'] |
59 | 64 | ); |
60 | 65 | $this->addWhere( 'page_id=fp_page_id' ); |
| 66 | + $this->addWhere( 'rev_id=fp_stable' ); |
61 | 67 | if ( !isset( $params['start'] ) && !isset( $params['end'] ) ) |
62 | 68 | $this->addWhere( 'fp_pending_since IS NOT NULL' ); |
| 69 | + |
63 | 70 | $this->addOption( |
64 | 71 | 'USE INDEX', |
65 | 72 | array( 'flaggedpages' => 'fp_pending_since' ) |
— | — | @@ -70,6 +77,8 @@ |
71 | 78 | 'page_namespace', |
72 | 79 | 'page_title', |
73 | 80 | 'page_latest', |
| 81 | + 'page_len', |
| 82 | + 'rev_len', |
74 | 83 | 'fp_stable', |
75 | 84 | 'fp_pending_since', |
76 | 85 | 'fp_quality' |
— | — | @@ -105,10 +114,10 @@ |
106 | 115 | 'title' => $title->getPrefixedText(), |
107 | 116 | 'revid' => intval( $row->page_latest ), |
108 | 117 | 'stable_revid' => intval( $row->fp_stable ), |
109 | | - 'pending_since' => |
110 | | - wfTimestamp( TS_ISO_8601, $row->fp_pending_since ), |
| 118 | + 'pending_since' => wfTimestamp( TS_ISO_8601, $row->fp_pending_since ), |
111 | 119 | 'flagged_level' => intval( $row->fp_quality ), |
112 | | - 'flagged_level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ) |
| 120 | + 'flagged_level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ), |
| 121 | + 'diff_size' => (int)$row->page_len - (int)$row->rev_len |
113 | 122 | ); |
114 | 123 | } else { |
115 | 124 | $resultPageSet->processDbRow( $row ); |
— | — | @@ -139,6 +148,11 @@ |
140 | 149 | 'older' |
141 | 150 | ) |
142 | 151 | ), |
| 152 | + 'maxsize' => array ( |
| 153 | + ApiBase::PARAM_TYPE => 'integer', |
| 154 | + ApiBase::PARAM_DFLT => null, |
| 155 | + ApiBase::PARAM_MIN => 0 |
| 156 | + ), |
143 | 157 | 'namespace' => array ( |
144 | 158 | ApiBase::PARAM_DFLT => |
145 | 159 | !$wgFlaggedRevsNamespaces ? |
— | — | @@ -167,12 +181,13 @@ |
168 | 182 | |
169 | 183 | public function getParamDescription() { |
170 | 184 | return array ( |
171 | | - 'start' => 'Start listing at this timestamp.', |
172 | | - 'end' => 'Stop listing at this timestamp.', |
173 | | - 'namespace' => 'The namespaces to enumerate.', |
174 | | - 'filterredir' => 'How to filter for redirects', |
175 | | - 'limit' => 'How many total pages to return.', |
176 | | - 'dir' => array( |
| 185 | + 'start' => 'Start listing at this timestamp.', |
| 186 | + 'end' => 'Stop listing at this timestamp.', |
| 187 | + 'namespace' => 'The namespaces to enumerate.', |
| 188 | + 'filterredir' => 'How to filter for redirects.', |
| 189 | + 'maxsize' => 'Maximum character count change size.', |
| 190 | + 'limit' => 'How many total pages to return.', |
| 191 | + 'dir' => array( |
177 | 192 | 'In which direction to list.', |
178 | 193 | '*newer: list the longest waiting pages first', |
179 | 194 | '*older: list the newest items first' |