* Probably want "$this->mIsGenerator = false;", not "$mIsGenerator = false;"
authorNick Jenkins <nickj@users.mediawiki.org>
Tue, 17 Oct 2006 09:27:39 +0000 (09:27 +0000)
committerNick Jenkins <nickj@users.mediawiki.org>
Tue, 17 Oct 2006 09:27:39 +0000 (09:27 +0000)
* 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.

includes/api/ApiBase.php
includes/api/ApiFeedWatchlist.php
includes/api/ApiMain.php
includes/api/ApiPageSet.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryWatchlist.php

index e0ed028..2bed8a8 100644 (file)
@@ -319,8 +319,10 @@ abstract class ApiBase {
                                case 'timestamp' :
                                        if ($multi)
                                                ApiBase :: dieDebug(__METHOD__, "Multi-values not supported for $paramName");
-                                       if (!preg_match('/^[0-9]{14}$/', $value))
+                                       if (!preg_match('/^[0-9]{14}$/', $value)) {
+                                               $valueName = ""; // TODO: initialization
                                                $this->dieUsage("Invalid value '$value' for timestamp parameter $paramName", "badtimestamp_{$valueName}");
+                                       }
                                        break;
                                default :
                                        ApiBase :: dieDebug(__METHOD__, "Param $paramName's type is unknown - $type");
@@ -365,8 +367,6 @@ abstract class ApiBase {
        * Validate the value against the minimum and user/bot maximum limits. Prints usage info on failure.
        */
        function validateLimit($varname, $value, $min, $max, $botMax) {
-               global $wgUser;
-
                if ($value < $min) {
                        $this->dieUsage("$varname may not be less than $min (set to $value)", $varname);
                }
index ac0bc35..c6dd72d 100644 (file)
@@ -63,7 +63,7 @@ class ApiFeedWatchlist extends ApiBase {
                $data = & $result->GetData();
 
                $feedItems = array ();
-               foreach ($data['query']['watchlist'] as $index => $info) {
+               foreach ($data['query']['watchlist'] as $index => $info) {
                        $title = $info['title'];
                        $titleUrl = Title :: newFromText($title)->getFullUrl();
                        $feedItems[] = new FeedItem($title, '', $titleUrl, $info['timestamp'], $info['user']);
index 9803e03..3f1ae8b 100644 (file)
@@ -142,7 +142,6 @@ class ApiMain extends ApiBase {
                                //
                                // User entered incorrect parameters - print usage screen
                                //
-                               $httpRespCode = $e->getCode();
                                $errMessage = array (
                                        'code' => $e->getCodeString(),
                                        'info' => $e->getMessage()
@@ -153,7 +152,6 @@ class ApiMain extends ApiBase {
                                //
                                // Something is seriously wrong
                                //
-                               $httpRespCode = 0;
                                $errMessage = array (
                                        'code' => 'internal_api_error',
                                        'info' => "Exception Caught: {$e->getMessage()}"
index ad3d804..e8587be 100644 (file)
@@ -234,7 +234,7 @@ class ApiPageSet extends ApiQueryBase {
         */
        public function populateFromRevisionIDs($revIDs) {
                $this->profileIn();
-               $pageIDs = array_map('intval', $revIDs); // paranoia
+               $revIDs = array_map('intval', $revIDs); // paranoia
                $this->initFromRevIDs($revIDs);
                $this->profileOut();
        }
index 09fd391..c5655f1 100644 (file)
@@ -46,7 +46,7 @@ abstract class ApiQueryBase extends ApiBase {
        }
 
        /**
-        * Get the main Query module 
+        * Get the main Query module
         */
        public function getQuery() {
                return $this->mQueryModule;
@@ -101,7 +101,7 @@ abstract class ApiQueryGeneratorBase extends ApiQueryBase {
 
        public function __construct($query, $moduleName, $paramPrefix = '') {
                parent :: __construct($query, $moduleName, $paramPrefix);
-               $mIsGenerator = false;
+               $this->mIsGenerator = false;
        }
 
        public function setGeneratorMode() {
index a2552f6..6b1a48f 100644 (file)
@@ -160,8 +160,6 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        if ($title->userCanRead()) {
 
                                if (is_null($resultPageSet)) {
-                                       $id = intval($row->page_id);
-
                                        $vals = array ();
                                        $vals['pageid'] = intval($row->page_id);
                                        $vals['revid'] = intval($row->rev_id);