r17068 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17067‎ | r17068 | r17069 >
Date:09:27, 17 October 2006
Author:nickj
Status:old
Tags:
Comment:
* Probably want "$this->mIsGenerator = false;", not "$mIsGenerator = false;"
* rm unused global declaration.
* rm references usage in a foreach iteration ($info does not seem to be assigned to anything, so no benefit to using refs).
* Define local var in error printout.
* rm a few local vars that look unused.
* Make paranoia check do something.
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiFeedWatchlist.php (modified) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)
  • /trunk/phase3/includes/api/ApiPageSet.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryBase.php
@@ -46,7 +46,7 @@
4747 }
4848
4949 /**
50 - * Get the main Query module
 50+ * Get the main Query module
5151 */
5252 public function getQuery() {
5353 return $this->mQueryModule;
@@ -101,7 +101,7 @@
102102
103103 public function __construct($query, $moduleName, $paramPrefix = '') {
104104 parent :: __construct($query, $moduleName, $paramPrefix);
105 - $mIsGenerator = false;
 105+ $this->mIsGenerator = false;
106106 }
107107
108108 public function setGeneratorMode() {
Index: trunk/phase3/includes/api/ApiBase.php
@@ -319,8 +319,10 @@
320320 case 'timestamp' :
321321 if ($multi)
322322 ApiBase :: dieDebug(__METHOD__, "Multi-values not supported for $paramName");
323 - if (!preg_match('/^[0-9]{14}$/', $value))
 323+ if (!preg_match('/^[0-9]{14}$/', $value)) {
 324+ $valueName = ""; // TODO: initialization
324325 $this->dieUsage("Invalid value '$value' for timestamp parameter $paramName", "badtimestamp_{$valueName}");
 326+ }
325327 break;
326328 default :
327329 ApiBase :: dieDebug(__METHOD__, "Param $paramName's type is unknown - $type");
@@ -365,8 +367,6 @@
366368 * Validate the value against the minimum and user/bot maximum limits. Prints usage info on failure.
367369 */
368370 function validateLimit($varname, $value, $min, $max, $botMax) {
369 - global $wgUser;
370 -
371371 if ($value < $min) {
372372 $this->dieUsage("$varname may not be less than $min (set to $value)", $varname);
373373 }
Index: trunk/phase3/includes/api/ApiMain.php
@@ -142,7 +142,6 @@
143143 //
144144 // User entered incorrect parameters - print usage screen
145145 //
146 - $httpRespCode = $e->getCode();
147146 $errMessage = array (
148147 'code' => $e->getCodeString(),
149148 'info' => $e->getMessage()
@@ -153,7 +152,6 @@
154153 //
155154 // Something is seriously wrong
156155 //
157 - $httpRespCode = 0;
158156 $errMessage = array (
159157 'code' => 'internal_api_error',
160158 'info' => "Exception Caught: {$e->getMessage()}"
Index: trunk/phase3/includes/api/ApiFeedWatchlist.php
@@ -63,7 +63,7 @@
6464 $data = & $result->GetData();
6565
6666 $feedItems = array ();
67 - foreach ($data['query']['watchlist'] as $index => & $info) {
 67+ foreach ($data['query']['watchlist'] as $index => $info) {
6868 $title = $info['title'];
6969 $titleUrl = Title :: newFromText($title)->getFullUrl();
7070 $feedItems[] = new FeedItem($title, '', $titleUrl, $info['timestamp'], $info['user']);
Index: trunk/phase3/includes/api/ApiPageSet.php
@@ -234,7 +234,7 @@
235235 */
236236 public function populateFromRevisionIDs($revIDs) {
237237 $this->profileIn();
238 - $pageIDs = array_map('intval', $revIDs); // paranoia
 238+ $revIDs = array_map('intval', $revIDs); // paranoia
239239 $this->initFromRevIDs($revIDs);
240240 $this->profileOut();
241241 }
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php
@@ -160,8 +160,6 @@
161161 if ($title->userCanRead()) {
162162
163163 if (is_null($resultPageSet)) {
164 - $id = intval($row->page_id);
165 -
166164 $vals = array ();
167165 $vals['pageid'] = intval($row->page_id);
168166 $vals['revid'] = intval($row->rev_id);