r81046 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81045‎ | r81046 | r81047 >
Date:19:13, 26 January 2011
Author:reedy
Status:ok
Tags:
Comment:
* (bug 26235) Wrong number of total revisions

Instead of using duplication in getRevCount, use the pager, and take from it's query

Makes getSpecializedWhereClause redundant, so now removed in all cases
Modified paths:
  • /trunk/extensions/CodeReview/ui/CodeRevisionAuthorView.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionListView.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionStatusView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/ui/CodeRevisionAuthorView.php
@@ -44,10 +44,6 @@
4545
4646 parent::execute();
4747 }
48 -
49 - function getSpecializedWhereClause() {
50 - return array( 'cr_author' => $this->mAuthor );
51 - }
5248 }
5349
5450 class SvnRevAuthorTablePager extends SvnRevTablePager {
Index: trunk/extensions/CodeReview/ui/CodeRevisionListView.php
@@ -187,6 +187,9 @@
188188 return $ret;
189189 }
190190
 191+ /**
 192+ * @return SvnRevTablePager
 193+ */
191194 function getPager() {
192195 return new SvnRevTablePager( $this );
193196 }
@@ -194,25 +197,21 @@
195198 /**
196199 * Get total number of revisions for this revision view
197200 *
 201+ * @var $dbr DatabaseBase
198202 * @return int Number of revisions
199203 */
200204 function getRevCount( $dbr ) {
201 - $tables = array( 'code_rev' );
202 - $selectFields = array( 'COUNT( DISTINCT cr_id ) AS rev_count' );
203 - // Count if code_rev where path matches
204 - if ( strlen( $this->mPath ) ) {
205 - $tables[] = 'code_paths';
206 - $whereCond = array(
207 - 'cr_repo_id' => $this->mRepo->getId(),
208 - 'cr_id = cp_rev_id',
209 - 'cp_path' => $this->mPath,
210 - );
211 - } else {
212 - // No path; count of code_rev
213 - $whereCond = array( 'cr_repo_id' => $this->mRepo->getId() );
214 - }
215 - $whereCond = array_merge( $whereCond, $this->getSpecializedWhereClause( $dbr ) );
216 - $result = $dbr->selectRow( $tables, $selectFields, $whereCond );
 205+ $query = $this->getPager()->getCountQuery();
 206+
 207+ $query['conds'] = array_merge( $query['conds'], $this->getSpecializedWhereClause() );
 208+
 209+ $result = $dbr->selectRow( $query['tables'],
 210+ $query['fields'],
 211+ $query['conds'],
 212+ __METHOD__,
 213+ $query['options'],
 214+ $query['join_conds']
 215+ );
217216 if ( $result ) {
218217 return intval( $result->rev_count );
219218 } else {
@@ -220,13 +219,6 @@
221220 }
222221 }
223222
224 - /**
225 - * @todo Document
226 - */
227 - function getSpecializedWhereClause() {
228 - return array();
229 - }
230 -
231223 function getRepo() {
232224 return $this->mRepo;
233225 }
@@ -278,6 +270,14 @@
279271 return $query;
280272 }
281273
 274+ function getCountQuery() {
 275+ $query = $this->getQueryInfo();
 276+
 277+ $query['fields'] = array( 'COUNT( DISTINCT cr_id ) AS rev_count' );
 278+ unset( $query['options']['GROUP BY'] );
 279+ return $query;
 280+ }
 281+
282282 function getSelectFields() {
283283 return array_unique(
284284 array( $this->getDefaultSort(),
Index: trunk/extensions/CodeReview/ui/CodeRevisionStatusView.php
@@ -10,10 +10,6 @@
1111 function getPager() {
1212 return new SvnRevStatusTablePager( $this, $this->mStatus );
1313 }
14 -
15 - function getSpecializedWhereClause() {
16 - return array( 'cr_status' => $this->mStatus );
17 - }
1814 }
1915
2016 class SvnRevStatusTablePager extends SvnRevTablePager {

Follow-up revisions

RevisionCommit summaryAuthorDate
r81047Followup r81046, dropping merge of $this->getSpecializedWhereClause() that is...reedy19:30, 26 January 2011

Status & tagging log