Index: trunk/extensions/CodeReview/ui/SpecialCode.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | |
13 | 13 | wfLoadExtensionMessages( 'CodeReview' ); |
14 | 14 | |
15 | | - if( !$this->userCanExecute( $wgUser ) ) { |
| 15 | + if ( !$this->userCanExecute( $wgUser ) ) { |
16 | 16 | $this->displayRestrictionError(); |
17 | 17 | return; |
18 | 18 | } |
— | — | @@ -120,7 +120,7 @@ |
121 | 121 | return $wgRequest->wasPosted() |
122 | 122 | && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) |
123 | 123 | && $wgUser->isAllowed( $permission ); |
124 | | - } |
| 124 | + } |
125 | 125 | |
126 | 126 | abstract function execute(); |
127 | 127 | |
— | — | @@ -132,10 +132,10 @@ |
133 | 133 | return $this->mRepo->authorWikiUser( $author ); |
134 | 134 | } |
135 | 135 | |
136 | | - function authorLink( $author, $extraParams=array() ) { |
| 136 | + function authorLink( $author, $extraParams = array() ) { |
137 | 137 | $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 ); |
140 | 140 | } |
141 | 141 | |
142 | 142 | function statusDesc( $status ) { |
Index: trunk/extensions/CodeReview/ui/CodeRevisionListView.php |
— | — | @@ -32,13 +32,9 @@ |
33 | 33 | |
34 | 34 | $this->showForm(); |
35 | 35 | |
36 | | - //get the total count across all pages |
| 36 | + // Get the total count across all pages |
37 | 37 | $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 ); |
43 | 39 | |
44 | 40 | $pager = $this->getPager(); |
45 | 41 | |
— | — | @@ -174,26 +170,39 @@ |
175 | 171 | return new SvnRevTablePager( $this ); |
176 | 172 | } |
177 | 173 | |
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 ) { |
179 | 180 | $tables = array( 'code_rev' ); |
180 | 181 | $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 ) ) { |
183 | 184 | $tables[] = 'code_paths'; |
184 | | - $whereCond = array('cr_repo_id' => $this->mRepo->getId(), |
| 185 | + $whereCond = array( |
| 186 | + 'cr_repo_id' => $this->mRepo->getId(), |
185 | 187 | 'cr_id = cp_rev_id', |
186 | 188 | ' cp_path' . $dbr->buildLike( $this->mPath, $dbr->anyString() ), |
187 | | - // performance |
| 189 | + // Performance |
188 | 190 | ' cp_rev_id > ' . ( $this->mRepo->getLastStoredRev() - 20000 ) |
189 | 191 | ); |
190 | 192 | // No path; count of code_rev |
191 | 193 | } else { |
192 | | - $whereCond = array('cr_repo_id' => $this->mRepo->getId()); |
| 194 | + $whereCond = array( 'cr_repo_id' => $this->mRepo->getId() ); |
193 | 195 | } |
194 | 196 | $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; |
196 | 202 | } |
197 | 203 | |
| 204 | + /** |
| 205 | + * @todo Document |
| 206 | + */ |
198 | 207 | function getSpecializedWhereClause( $dbr ) { |
199 | 208 | return array(); |
200 | 209 | } |
— | — | @@ -282,7 +291,7 @@ |
283 | 292 | |
284 | 293 | function formatRevValue( $name, $value, $row ) { |
285 | 294 | 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(); |
287 | 296 | |
288 | 297 | switch( $name ) { |
289 | 298 | case 'selectforchange': |