r104370 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104369‎ | r104370 | r104371 >
Date:22:56, 27 November 2011
Author:reedy
Status:reverted (Comments)
Tags:
Comment:
Comments

A fixme on a wrong function call
Modified paths:
  • /trunk/extensions/ContributionReporting/ContributionHistory_body.php (modified) (history)
  • /trunk/extensions/ContributionReporting/ContributionReporting.php (modified) (history)
  • /trunk/extensions/ContributionReporting/ContributionStatistics_body.php (modified) (history)
  • /trunk/extensions/ContributionReporting/ContributionTrackingStatistics_body.php (modified) (history)
  • /trunk/extensions/ContributionReporting/FundraiserStatistics_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionReporting/ContributionReporting.php
@@ -116,17 +116,29 @@
117117 $wgHooks['ParserFirstCallInit'][] = 'efContributionReportingSetup';
118118 $wgHooks['LanguageGetMagic'][] = 'efContributionReportingTotal_Magic';
119119
 120+/**
 121+ * @param $parser Parser
 122+ * @return bool
 123+ */
120124 function efContributionReportingSetup( $parser ) {
121125 $parser->setFunctionHook( 'contributiontotal', 'efContributionReportingTotal_Render' );
122126 return true;
123127 }
124128
 129+/**
 130+ * @param $magicWords array
 131+ * @param $langCode string
 132+ * @return bool
 133+ */
125134 function efContributionReportingTotal_Magic( &$magicWords, $langCode ) {
126135 $magicWords['contributiontotal'] = array( 0, 'contributiontotal' );
127136 return true;
128137 }
129138
130139 // Automatically use a local or special database connection
 140+/**
 141+ * @return DatabaseMysql
 142+ */
131143 function efContributionReportingConnection() {
132144 global $wgContributionReportingDBserver, $wgContributionReportingDBname;
133145 global $wgContributionReportingDBuser, $wgContributionReportingDBpassword;
@@ -145,6 +157,9 @@
146158 return $db;
147159 }
148160
 161+/**
 162+ * @return DatabaseMysql
 163+ */
149164 function efContributionTrackingConnection() {
150165 global $wgContributionTrackingDBserver, $wgContributionTrackingDBname;
151166 global $wgContributionTrackingDBuser, $wgContributionTrackingDBpassword;
@@ -163,6 +178,11 @@
164179 return $db;
165180 }
166181
 182+/**
 183+ * @param $start
 184+ * @param $fudgeFactor
 185+ * @return string
 186+ */
167187 function efContributionReportingTotal( $start, $fudgeFactor ) {
168188 $db = efContributionReportingConnection();
169189 #$db = wfGetDB( DB_MASTER );
@@ -185,6 +205,9 @@
186206 return $output;
187207 }
188208
 209+/**
 210+ * @return string
 211+ */
189212 function efContributionReportingTotal_Render() {
190213 $args = func_get_args();
191214 array_shift( $args );
Index: trunk/extensions/ContributionReporting/ContributionTrackingStatistics_body.php
@@ -205,7 +205,12 @@
206206
207207 /* Query Functions */
208208
209 - // Totals for today
 209+ /**
 210+ * Totals for today
 211+ *
 212+ * @param $timestamp string
 213+ * @return array
 214+ */
210215 public function getDayTotals( $timestamp = 0 ) {
211216 $range = array();
212217 $end_format = 'Ymd235959';
@@ -250,15 +255,21 @@
251256
252257 );
253258
 259+ $result = array();
254260 foreach ( $res as $row ) {
255 - foreach( $row as $key => $value ) {
 261+ foreach( $row as $value ) {
256262 $result[] = $value;
257263 }
258264 }
259265 return $result;
260266 }
261267
262 - // Given a day figure out what its week bounds are
 268+ /**
 269+ * Given a day figure out what its week bounds are
 270+ *
 271+ * @param $day
 272+ * @return array
 273+ */
263274 public function weekRange( $day ) {
264275 $day = wfTimestamp( TS_UNIX, $day );
265276 $start = ( date( 'w', $day ) == 0) ? $day : strtotime('last sunday', $day ); // Use current Sunday
Index: trunk/extensions/ContributionReporting/FundraiserStatistics_body.php
@@ -15,7 +15,7 @@
1616 }
1717
1818 public function execute( $sub ) {
19 - global $wgRequest, $wgOut, $wgUser, $wgLang, $wgScriptPath, $egFundraiserStatisticsFundraisers;
 19+ global $wgRequest, $wgOut, $wgLang, $wgScriptPath, $egFundraiserStatisticsFundraisers;
2020
2121 $showYear = array();
2222 foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) {
@@ -249,7 +249,7 @@
250250 Xml::tags(
251251 'table',
252252 array( 'cellpadding' => 0, 'cellspacing' => 0, 'border' => 0 ),
253 - Xml::tags( 'tr', null, implode( $chart['data'] ) )
 253+ Xml::tags( 'tr', null, implode( $chart['data'] ) ) // FIXME: Missing parameter to implode
254254 )
255255 );
256256 $first = false;
@@ -307,7 +307,7 @@
308308 );
309309 $result = array();
310310 $ytd = 0;
311 - while ( $row = $dbr->fetchRow( $select ) ) {
 311+ foreach( $select as $row ) {
312312 $row[] = $ytd += $row[1]; // YTD
313313 $result[] = $row;
314314 }
@@ -371,6 +371,10 @@
372372 return null;
373373 }
374374
 375+ /**
 376+ * @param $values
 377+ * @return string
 378+ */
375379 private function dropDownList ( $values ) {
376380 $dropDown = '';
377381 foreach ( $values as $value ) {
Index: trunk/extensions/ContributionReporting/ContributionHistory_body.php
@@ -11,7 +11,6 @@
1212 $wgOut->redirect( SpecialPage::getTitleFor( 'FundraiserStatistics' )->getFullURL() );
1313 return;
1414
15 -
1615 if ( !preg_match( '/^[a-z-]+$/', $language ) ) {
1716 $language = 'en';
1817 }
Index: trunk/extensions/ContributionReporting/ContributionStatistics_body.php
@@ -274,6 +274,10 @@
275275
276276 /* Query Functions */
277277
 278+ /**
 279+ * @param $limit int
 280+ * @return array
 281+ */
278282 public function getDailyTotals( $limit = 30 ) {
279283 // Get connection
280284 $dbr = efContributionReportingConnection();
@@ -369,6 +373,9 @@
370374 return $totals;
371375 }
372376
 377+ /**
 378+ * @return array
 379+ */
373380 public function getCurrencyTotals() {
374381 // Get connection
375382 $dbr = efContributionReportingConnection();
@@ -498,6 +505,10 @@
499506 );
500507 }
501508
 509+ /**
 510+ * @param $dbr DatabaseBase
 511+ * @return array
 512+ */
502513 protected function dateConds( $dbr ) {
503514 return
504515 array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r104586MFT r104062, r104247, r104248, r104362, r104370, r104372, r104424, r104425, r...awjrichards20:22, 29 November 2011
r104889Revert r104370awjrichards19:55, 1 December 2011

Comments

#Comment by Awjrichards (talk | contribs)   19:55, 1 December 2011
-				while ( $row = $dbr->fetchRow( $select ) ) {
+				foreach( $select as $row ) {
 					$row[] = $ytd += $row[1]; // YTD
 					$result[] = $row;
 				}

This causes a php fatal error.

Status & tagging log