r72305 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72304‎ | r72305 | r72306 >
Date:19:11, 3 September 2010
Author:reedy
Status:deferred
Tags:
Comment:
Some code/query updates per problems noticed on prototype
Modified paths:
  • /trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php
@@ -105,24 +105,23 @@
106106 if ( $params['userrating'] && $userRatedArticle ) {
107107 $revid = isset( $params['revid'] ) ? $params['revid'] : $ratings[$pageId]['revid'];
108108
109 - $this->resetQueryParams();
 109+ $dbr = wfGetDb( DB_SLAVE );
110110
111 - $this->addTables( 'revision' );
112 - $this->addFields( array( 'COUNT(rev_id) AS norevs', 'rev_page' ) );
 111+ $res = $dbr->selectField(
 112+ 'revision',
 113+ 'COUNT(*) AS norevs',
 114+ array(
 115+ 'rev_page' => $params['pageid'],
 116+ 'rev_id > ' . $revid
 117+ ),
 118+ __METHOD__
 119+ );
113120
114 - $this->addWhereFld( 'rev_page', $params['pageid'] );
115 - $this->addWhere( 'rev_id > ' . $revid );
116 -
117 - $res = $this->select( __METHOD__ );
118 -
119121 global $wgArticleAssessmentStaleCount;
120122
121 - if ( $res ) {
122 - $noOfRevs = $res->fetchRow()->norevs;
123 - if ( $noOfRevs > $wgArticleAssessmentStaleCount ) {
124 - //it's stale!
125 - $ratings[$params['pageid']]['stale'] = intval( $noOfRevs );
126 - }
 123+ if ( $res && (int)$res > $wgArticleAssessmentStaleCount ) {
 124+ //it's stale!
 125+ $ratings[$params['pageid']]['stale'] = intval( $res );
127126 }
128127 }
129128
@@ -187,7 +186,7 @@
188187 return array(
189188 'api.php?action=query&list=articleassessment',
190189 'api.php?action=query&list=articleassessment&aapageid=1',
191 - 'api.php?action=query&list=articleassessment&aapageid=1&userrating',
 190+ 'api.php?action=query&list=articleassessment&aapageid=1&aauserrating',
192191 );
193192 }
194193

Status & tagging log