r59533 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59532‎ | r59533 | r59534 >
Date:23:00, 28 November 2009
Author:aaron
Status:ok
Tags:
Comment:
* (bug 14345) Added maxsize to oldreviewedpages API
* Worked around max size filter bug (unsigned int overflow). Should run on PG too. (WMF and my other box don't need this somehow)
Modified paths:
  • /trunk/extensions/FlaggedRevs/api/ApiQueryOldreviewedpages.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/OldReviewedPages_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/specialpages/OldReviewedPages_body.php
@@ -286,9 +286,9 @@
287287 public $mForm, $mConds;
288288 private $category, $namespace;
289289
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+ ) {
293293 $this->mForm = $form;
294294 # Must be a content page...
295295 global $wgFlaggedRevsNamespaces;
@@ -305,7 +305,7 @@
306306 # Sanity check level: 0 = sighted; 1 = quality; 2 = pristine
307307 $this->level = ($level >= 0 && $level <= 2) ? $level : -1;
308308 $this->category = $category ? str_replace(' ','_',$category) : NULL;
309 - $this->size = $size ? $size : NULL;
 309+ $this->size = ($size !== null) ? intval($size) : NULL;
310310 $this->watched = (bool)$watched;
311311 $this->stable = $stable && !FlaggedRevs::showStableByDefault();
312312 parent::__construct();
@@ -400,7 +400,10 @@
401401 }
402402 # Filter by bytes changed
403403 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);
405408 }
406409 return array(
407410 'tables' => $tables,
Index: trunk/extensions/FlaggedRevs/api/ApiQueryOldreviewedpages.php
@@ -44,12 +44,17 @@
4545 $params = $this->extractRequestParams();
4646
4747 // Construct SQL Query
48 - $this->addTables( array( 'page', 'flaggedpages' ) );
 48+ $this->addTables( array( 'page', 'flaggedpages', 'revision' ) );
4949 $this->addWhereFld( 'page_namespace', $params['namespace'] );
5050 if( $params['filterredir'] == 'redirects' )
5151 $this->addWhereFld( 'page_is_redirect', 1 );
5252 if( $params['filterredir'] == 'nonredirects' )
5353 $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']) );
5459 $this->addWhereRange(
5560 'fp_pending_since',
5661 $params['dir'],
@@ -57,8 +62,10 @@
5863 $params['end']
5964 );
6065 $this->addWhere( 'page_id=fp_page_id' );
 66+ $this->addWhere( 'rev_id=fp_stable' );
6167 if ( !isset( $params['start'] ) && !isset( $params['end'] ) )
6268 $this->addWhere( 'fp_pending_since IS NOT NULL' );
 69+
6370 $this->addOption(
6471 'USE INDEX',
6572 array( 'flaggedpages' => 'fp_pending_since' )
@@ -70,6 +77,8 @@
7178 'page_namespace',
7279 'page_title',
7380 'page_latest',
 81+ 'page_len',
 82+ 'rev_len',
7483 'fp_stable',
7584 'fp_pending_since',
7685 'fp_quality'
@@ -105,10 +114,10 @@
106115 'title' => $title->getPrefixedText(),
107116 'revid' => intval( $row->page_latest ),
108117 '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 ),
111119 '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
113122 );
114123 } else {
115124 $resultPageSet->processDbRow( $row );
@@ -139,6 +148,11 @@
140149 'older'
141150 )
142151 ),
 152+ 'maxsize' => array (
 153+ ApiBase::PARAM_TYPE => 'integer',
 154+ ApiBase::PARAM_DFLT => null,
 155+ ApiBase::PARAM_MIN => 0
 156+ ),
143157 'namespace' => array (
144158 ApiBase::PARAM_DFLT =>
145159 !$wgFlaggedRevsNamespaces ?
@@ -167,12 +181,13 @@
168182
169183 public function getParamDescription() {
170184 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(
177192 'In which direction to list.',
178193 '*newer: list the longest waiting pages first',
179194 '*older: list the newest items first'

Follow-up revisions

RevisionCommit summaryAuthorDate
r59538* Added filterwatched to olreviewedpages API (bug 14345)...aaron00:29, 29 November 2009
r60520* Added category filter to oldreviewedpages API (bug 14345)...aaron01:38, 31 December 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41809(bug 14345) Add API module for FlaggedRevs. Patch by Paul Copperman. I have N...catrope14:27, 7 October 2008

Status & tagging log