r100305 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100304‎ | r100305 | r100306 >
Date:00:43, 20 October 2011
Author:aaron
Status:ok
Tags:
Comment:
* Added a proper Pager::doBatchLookups() function
* Made HistoryPager use a link batch via Pager::doBatchLookups()
Modified paths:
  • /trunk/phase3/includes/HistoryPage.php (modified) (history)
  • /trunk/phase3/includes/Pager.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HistoryPage.php
@@ -382,6 +382,19 @@
383383 return $s;
384384 }
385385
 386+ function doBatchLookups() {
 387+ # Do a link batch query
 388+ $this->mResult->seek( 0 );
 389+ $batch = new LinkBatch();
 390+ # Give some pointers to make (last) links
 391+ foreach ( $this->mResult as $row ) {
 392+ $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_name ) );
 393+ $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_name ) );
 394+ }
 395+ $batch->execute();
 396+ $this->mResult->seek( 0 );
 397+ }
 398+
386399 /**
387400 * Creates begin of history list with a submit button
388401 *
Index: trunk/phase3/includes/Pager.php
@@ -325,10 +325,13 @@
326326 *
327327 * @return String
328328 */
329 - function getBody() {
 329+ public function getBody() {
330330 if ( !$this->mQueryDone ) {
331331 $this->doQuery();
332332 }
 333+ # Do any special query batches before display
 334+ $this->doBatchLookups();
 335+
333336 # Don't use any extra rows returned by the query
334337 $numRows = min( $this->mResult->numRows(), $this->mLimit );
335338
@@ -385,12 +388,20 @@
386389 }
387390
388391 /**
 392+ * Called from getBody(), before getStartBody() is called. This
 393+ * will be called even if there are no rows in the result set.
 394+ *
 395+ * @return void
 396+ */
 397+ protected function doBatchLookups() {}
 398+
 399+ /**
389400 * Hook into getBody(), allows text to be inserted at the start. This
390401 * will be called even if there are no rows in the result set.
391402 *
392403 * @return String
393404 */
394 - function getStartBody() {
 405+ protected function getStartBody() {
395406 return '';
396407 }
397408
@@ -399,7 +410,7 @@
400411 *
401412 * @return String
402413 */
403 - function getEndBody() {
 414+ protected function getEndBody() {
404415 return '';
405416 }
406417
@@ -409,7 +420,7 @@
410421 *
411422 * @return String
412423 */
413 - function getEmptyBody() {
 424+ protected function getEmptyBody() {
414425 return '';
415426 }
416427

Follow-up revisions

RevisionCommit summaryAuthorDate
r101629Followup r100305, don't try to do a batch query for an empty result (which w...johnduhart15:15, 2 November 2011

Status & tagging log