r87088 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87087‎ | r87088 | r87089 >
Date:17:22, 28 April 2011
Author:reedy
Status:ok
Tags:
Comment:
Whitespace cleanup

Remove unused variables

Remove some API wheel reinventing
Modified paths:
  • /trunk/extensions/ClickTracking/ApiClickTracking.php (modified) (history)
  • /trunk/extensions/ClickTracking/ApiSpecialClickTracking.php (modified) (history)
  • /trunk/extensions/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /trunk/extensions/EmailCapture/EmailCaptureHooks.php (modified) (history)
  • /trunk/extensions/EmailCapture/SpecialEmailCapture.php (modified) (history)
  • /trunk/extensions/EmailCapture/api/ApiEmailCapture.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ClickTracking/ClickTracking.hooks.php
@@ -91,7 +91,6 @@
9292 return true;
9393 }
9494
95 -
9695 //adds a bucket-testing campaign to the active campaigns
9796 public static function addCampaign($localBasePath, $remoteExtPath, $name ){
9897 global $wgResourceModules;
@@ -108,9 +107,7 @@
109108 ( array ) $wgResourceModules['ext.UserBuckets']['dependencies'],
110109 array("ext.UserBuckets.$name"));
111110 }
112 -
113 -
114 -
 111+
115112 /**
116113 * Get event ID from name
117114 *
@@ -140,9 +137,6 @@
141138 return $id_num === false ? 0 : $id_num;
142139 }
143140
144 -
145 -
146 -
147141 /**
148142 * Returns bucket information
149143 * @return Array array of buckets, or null
@@ -230,8 +224,6 @@
231225
232226 $dbw->commit();
233227 return ($db_status && $db_status_buckets);
234 -
235 -
236228 }
237229
238230 public static function editPageShowEditFormFields( $editPage, $output ) {
Index: trunk/extensions/ClickTracking/ApiClickTracking.php
@@ -18,11 +18,10 @@
1919 * @see includes/api/ApiBase#execute()
2020 */
2121 public function execute() {
22 - global $wgUser, $wgTitle, $wgClickTrackContribGranularity1, $wgClickTrackContribGranularity2,
 22+ global $wgUser, $wgClickTrackContribGranularity1, $wgClickTrackContribGranularity2,
2323 $wgClickTrackContribGranularity3;
2424
2525 $params = $this->extractRequestParams();
26 - $this->validateParams( $params );
2726 $eventid_to_lookup = $params['eventid'];
2827 $sessionId = $params['token'];
2928 $namespace = $params['namespacenumber'];
@@ -81,19 +80,6 @@
8281 }
8382 }
8483
85 - /**
86 - * Required parameter check
87 - * @param $params params extracted from the POST
88 - */
89 - protected function validateParams( $params ) {
90 - $required = array( 'eventid', 'token', 'namespacenumber' );
91 - foreach ( $required as $arg ) {
92 - if ( !isset( $params[$arg] ) ) {
93 - $this->dieUsageMsg( array( 'missingparam', $arg ) );
94 - }
95 - }
96 - }
97 -
9884 public function getParamDescription() {
9985 return array(
10086 'eventid' => 'string of eventID',
@@ -110,19 +96,20 @@
11197 );
11298 }
11399
114 - public function getPossibleErrors() {
115 - return array_merge( parent::getPossibleErrors(), array(
116 - array( 'missingparam', 'eventid' ),
117 - array( 'missingparam', 'token' ),
118 - array( 'missingparam', 'namespacenumber'),
119 - ) );
120 - }
121 -
122100 public function getAllowedParams() {
123101 return array(
124 - 'eventid' => null,
125 - 'namespacenumber' => null,
126 - 'token' => null,
 102+ 'eventid' => array(
 103+ ApiBase::PARAM_TYPE => 'string',
 104+ ApiBase::PARAM_REQUIRED => true,
 105+ ),
 106+ 'namespacenumber' => array(
 107+ ApiBase::PARAM_TYPE => 'namespace',
 108+ ApiBase::PARAM_REQUIRED => true,
 109+ ),
 110+ 'token' => array(
 111+ ApiBase::PARAM_TYPE => 'string',
 112+ ApiBase::PARAM_REQUIRED => true,
 113+ ),
127114 'redirectto' => null,
128115 'additional' => null
129116 );
Index: trunk/extensions/ClickTracking/ApiSpecialClickTracking.php
@@ -34,7 +34,6 @@
3535 $this->getResult()->addValue( array( 'tablevals' ), 'vals', $tableData );
3636 } else {
3737 // Chart data
38 - $click_data = array();
3938 try {
4039 $click_data = SpecialClickTracking::getChartData( $eventId, $startDate, $endDate, $increment, $userDefString );
4140 $this->getResult()->addValue( array( 'datapoints' ), 'expert', $click_data['expert'] );
@@ -49,16 +48,9 @@
5049 /**
5150 * Required parameter check
5251 *
53 - * @param $params params extracted from the POST
 52+ * @param $params array params extracted from the POST
5453 */
5554 protected function validateParams( $params ) {
56 - $required = array( 'eventid', 'startdate', 'enddate', 'increment', 'userdefs' );
57 - foreach ( $required as $arg ) {
58 - if ( !isset( $params[$arg] ) ) {
59 - $this->dieUsageMsg( array( 'missingparam', $arg ) );
60 - }
61 - }
62 -
6355 // Check if event id parses to an int greater than zero
6456 if ( (int) $params['eventid'] < 0 ) {
6557 $this->dieUsage( 'Invalid event ID', 'badeventid' );
@@ -73,7 +65,7 @@
7466 }
7567
7668 // Check if increment is a positive integer
77 - if ( (int) $params['increment'] <= 0 ) {
 69+ if ( $params['increment'] <= 0 ) {
7870 $this->dieUsage( 'Invalid increment', 'badincrement' );
7971 }
8072
@@ -101,11 +93,6 @@
10294
10395 public function getPossibleErrors() {
10496 return array_merge( parent::getPossibleErrors(), array(
105 - array( 'missingparam', 'eventid' ),
106 - array( 'missingparam', 'startdate' ),
107 - array( 'missingparam', 'enddate' ),
108 - array( 'missingparam', 'increment' ),
109 - array( 'missingparam', 'userdefs' ),
11097 array( 'code' => 'badeventid', 'info' => 'Invalid event ID' ),
11198 array( 'code' => 'badstartdate', 'info' => 'startdate not in YYYYMMDD format: <<\'startdate\'>>' ),
11299 array( 'code' => 'badenddate', 'info' => 'enddate not in YYYYMMDD format: <<\'enddate\'>>' ),
@@ -118,21 +105,26 @@
119106 return array(
120107 'eventid' => array(
121108 ApiBase::PARAM_TYPE => 'integer',
122 - ApiBase::PARAM_MIN => 1
 109+ ApiBase::PARAM_MIN => 1,
 110+ ApiBase::PARAM_REQUIRED => true,
123111 ),
124112 'startdate' => array(
125 - ApiBase::PARAM_TYPE => 'integer'
 113+ ApiBase::PARAM_TYPE => 'integer',
 114+ ApiBase::PARAM_REQUIRED => true,
126115 ),
127116 'enddate' => array(
128 - ApiBase::PARAM_TYPE => 'integer'
 117+ ApiBase::PARAM_TYPE => 'integer',
 118+ ApiBase::PARAM_REQUIRED => true,
129119 ),
130120 'increment' => array(
131121 ApiBase::PARAM_TYPE => 'integer',
132122 ApiBase::PARAM_MIN => 1,
133 - ApiBase::PARAM_MAX => 365 // 1 year
 123+ ApiBase::PARAM_MAX => 365, // 1 year
 124+ ApiBase::PARAM_REQUIRED => true,
134125 ),
135126 'userdefs' => array(
136 - ApiBase::PARAM_TYPE => 'string'
 127+ ApiBase::PARAM_TYPE => 'string',
 128+ ApiBase::PARAM_REQUIRED => true,
137129 ),
138130 'tabledata' => array(
139131 ApiBase::PARAM_TYPE => 'integer'
Index: trunk/extensions/EmailCapture/SpecialEmailCapture.php
@@ -7,7 +7,7 @@
88 }
99
1010 public function execute( $par ) {
11 - global $wgOut, $wgUser, $wgRequest;
 11+ global $wgOut, $wgRequest;
1212
1313 $this->setHeaders();
1414
Index: trunk/extensions/EmailCapture/EmailCaptureHooks.php
@@ -5,6 +5,9 @@
66 class EmailCaptureHooks {
77 /**
88 * LoadExtensionSchemaUpdates hook
 9+ *
 10+ * @param $updater DatabaseUpdater
 11+ * @return bool
912 */
1013 public static function loadExtensionSchemaUpdates( $updater ) {
1114 $db = $updater->getDB();
Index: trunk/extensions/EmailCapture/api/ApiEmailCapture.php
@@ -31,7 +31,7 @@
3232
3333 if ( $dbw->affectedRows() ) {
3434 // Send auto-response
35 - global $wgUser, $wgEmailCaptureSendAutoResponse, $wgEmailCaptureAutoResponse;
 35+ global $wgEmailCaptureSendAutoResponse, $wgEmailCaptureAutoResponse;
3636 $title = SpecialPage::getTitleFor( 'EmailCapture' );
3737 $link = $title->getFullURL();
3838 $fullLink = $title->getFullURL( array( 'verify' => $code ) );

Status & tagging log