r67557 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67556‎ | r67557 | r67558 >
Date:19:33, 7 June 2010
Author:kaldari
Status:deferred
Tags:
Comment:
Fixing wrong offset value.
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
@@ -42,7 +42,9 @@
4343 wfLoadExtensionMessages( 'CentralNotice' );
4444 }
4545
46 - // Handle different types of page requests
 46+ /*
 47+ * Handle different types of page requests.
 48+ */
4749 function execute( $sub ) {
4850 global $wgOut, $wgUser, $wgRequest;
4951
@@ -141,6 +143,9 @@
142144 $this->showList();
143145 }
144146
 147+ /*
 148+ * Show a list of available templates. Newer templates are shown first.
 149+ */
145150 function showList() {
146151 global $wgOut, $wgUser, $wgRequest, $wgLang;
147152
@@ -537,7 +542,10 @@
538543 $article->doEdit( $translation, '', EDIT_FORCE_BOT );
539544 }
540545
541 - function queryTemplates($offset, $limit) {
 546+ /*
 547+ * Return an array of templates constrained by offset and limit parameters.
 548+ */
 549+ function queryTemplates( $offset, $limit ) {
542550 $dbr = wfGetDB( DB_SLAVE );
543551 $conds = array();
544552 $options['ORDER BY'] = $this->indexField . ' DESC';
@@ -563,7 +571,6 @@
564572 foreach ( $res as $row ) {
565573 array_push( $templates, $row->tmp_name );
566574 }
567 -
568575 return $templates;
569576 }
570577
@@ -770,7 +777,7 @@
771778 function getPagingQueries( $offset, $limit ) {
772779 $dbr = wfGetDB( DB_SLAVE );
773780 if ( $offset ) {
774 - // prev
 781+ // Build previous link
775782 $templates = array();
776783 $conds = array();
777784 $options['ORDER BY'] = $this->indexField . ' ASC';
@@ -783,14 +790,14 @@
784791 $options
785792 );
786793 foreach ( $res as $row ) {
787 - array_push( $templates, $row->tmp_name );
 794+ array_push( $templates, $row->tmp_id );
788795 }
789796 if ( count( $templates ) == $limit + 1 ) {
790797 $prev = array( 'offset' => end( $templates ), 'limit' => $limit );
791798 } else {
792799 $prev = array( 'offset' => '0', 'limit' => $limit );
793800 }
794 - // next
 801+ // Build next link
795802 $templates = array();
796803 $conds = array();
797804 $conds[] = $this->indexField . '<' . $this->mDb->addQuotes( $offset );
@@ -803,7 +810,7 @@
804811 $options
805812 );
806813 foreach ( $res as $row ) {
807 - array_push( $templates, $row->tmp_name );
 814+ array_push( $templates, $row->tmp_id );
808815 }
809816 if ( count( $templates ) == $limit + 1 ) {
810817 end( $templates );
@@ -812,8 +819,9 @@
813820 $next = false;
814821 }
815822 } else {
 823+ // No previous link needed
816824 $prev = false;
817 - // next
 825+ // Build next link
818826 $templates = array();
819827 $options['ORDER BY'] = $this->indexField . ' DESC';
820828 $options['LIMIT'] = intval( $limit ) + 1;
@@ -824,7 +832,7 @@
825833 $options
826834 );
827835 while ( $row = $dbr->fetchObject( $res ) ) {
828 - array_push( $templates, $row->tmp_name );
 836+ array_push( $templates, $row->tmp_id );
829837 }
830838 if ( count( $templates ) == $limit + 1 ) {
831839 end( $templates );
@@ -843,7 +851,7 @@
844852 * of HTML.
845853 */
846854 function getPagingLinks( $linkTexts, $offset, $limit, $disabledTexts = array() ) {
847 - $queries = $this->getPagingQueries($offset, $limit);
 855+ $queries = $this->getPagingQueries( $offset, $limit );
848856 $links = array();
849857 foreach ( $queries as $type => $query ) {
850858 if ( $query !== false ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r675581.16wmf4: MFT r67557catrope19:40, 7 June 2010

Status & tagging log