r62887 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62886‎ | r62887 | r62888 >
Date:19:34, 23 February 2010
Author:btongminh
Status:ok
Tags:
Comment:
* CodeRevisionListView::getRevCountQuery renamed to CodeRevisionListView::getRevCount, because it returns the rev count and not the rev count query. Also made it return a plain int instead of a DatabaseResult.
* Some whitespace tweaks
Modified paths:
  • /trunk/extensions/CodeReview/ui/CodeRevisionListView.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/SpecialCode.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/ui/SpecialCode.php
@@ -11,7 +11,7 @@
1212
1313 wfLoadExtensionMessages( 'CodeReview' );
1414
15 - if( !$this->userCanExecute( $wgUser ) ) {
 15+ if ( !$this->userCanExecute( $wgUser ) ) {
1616 $this->displayRestrictionError();
1717 return;
1818 }
@@ -120,7 +120,7 @@
121121 return $wgRequest->wasPosted()
122122 && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) )
123123 && $wgUser->isAllowed( $permission );
124 - }
 124+ }
125125
126126 abstract function execute();
127127
@@ -132,10 +132,10 @@
133133 return $this->mRepo->authorWikiUser( $author );
134134 }
135135
136 - function authorLink( $author, $extraParams=array() ) {
 136+ function authorLink( $author, $extraParams = array() ) {
137137 $repo = $this->mRepo->getName();
138 - $special = SpecialPage::getTitleFor( 'Code', "$repo/author/$author" );
139 - return $this->mSkin->link( $special, htmlspecialchars( $author ), array(), $extraParams);
 138+ $special = SpecialPage::getTitleFor( 'Code', "$repo/author/$author" );
 139+ return $this->mSkin->link( $special, htmlspecialchars( $author ), array(), $extraParams );
140140 }
141141
142142 function statusDesc( $status ) {
Index: trunk/extensions/CodeReview/ui/CodeRevisionListView.php
@@ -32,13 +32,9 @@
3333
3434 $this->showForm();
3535
36 - //get the total count across all pages
 36+ // Get the total count across all pages
3737 $dbr = wfGetDB( DB_SLAVE );
38 - $revCountRes = $this->getRevCountQuery( $dbr );
39 - $revCount = 0;
40 - if ( $revCountRes !== false ) {
41 - $revCount = $revCountRes->rev_count;
42 - }
 38+ $revCount = $this->getRevCount( $dbr );
4339
4440 $pager = $this->getPager();
4541
@@ -174,26 +170,39 @@
175171 return new SvnRevTablePager( $this );
176172 }
177173
178 - function getRevCountQuery( $dbr ) {
 174+ /**
 175+ * Get total number of revisions for this revision view
 176+ *
 177+ * @return int Number of revisions
 178+ */
 179+ function getRevCount( $dbr ) {
179180 $tables = array( 'code_rev' );
180181 $selectFields = array( 'COUNT( DISTINCT cr_id ) AS rev_count' );
181 - // count if code_rev where path matches
182 - if ( strlen($this->mPath) ) {
 182+ // Count if code_rev where path matches
 183+ if ( strlen( $this->mPath ) ) {
183184 $tables[] = 'code_paths';
184 - $whereCond = array('cr_repo_id' => $this->mRepo->getId(),
 185+ $whereCond = array(
 186+ 'cr_repo_id' => $this->mRepo->getId(),
185187 'cr_id = cp_rev_id',
186188 ' cp_path' . $dbr->buildLike( $this->mPath, $dbr->anyString() ),
187 - // performance
 189+ // Performance
188190 ' cp_rev_id > ' . ( $this->mRepo->getLastStoredRev() - 20000 )
189191 );
190192 // No path; count of code_rev
191193 } else {
192 - $whereCond = array('cr_repo_id' => $this->mRepo->getId());
 194+ $whereCond = array( 'cr_repo_id' => $this->mRepo->getId() );
193195 }
194196 $whereCond = array_merge( $whereCond, $this->getSpecializedWhereClause( $dbr ) );
195 - return $dbr->selectRow( $tables, $selectFields, $whereCond );
 197+ $result = $dbr->selectRow( $tables, $selectFields, $whereCond );
 198+ if ( $result )
 199+ return $result->rev_count;
 200+ else
 201+ return 0;
196202 }
197203
 204+ /**
 205+ * @todo Document
 206+ */
198207 function getSpecializedWhereClause( $dbr ) {
199208 return array();
200209 }
@@ -282,7 +291,7 @@
283292
284293 function formatRevValue( $name, $value, $row ) {
285294 global $wgLang;
286 - $pathQuery = ( strlen($this->mView->mPath) ) ? array('path' => $this->mView->mPath) : array();
 295+ $pathQuery = ( strlen( $this->mView->mPath ) ) ? array( 'path' => $this->mView->mPath ) : array();
287296
288297 switch( $name ) {
289298 case 'selectforchange':

Follow-up revisions

RevisionCommit summaryAuthorDate
r76885* Per CR on r62646, formatNum() $revCount...demon16:15, 17 November 2010

Status & tagging log