r107241 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107240‎ | r107241 | r107242 >
Date:23:29, 24 December 2011
Author:reedy
Status:ok
Tags:
Comment:
Normalise return statements

SpecialPage::execute doesn't use a return value, so no point sending one. Also removes a little bit of discrepancy between code
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackNovaHost.php (modified) (history)
  • /trunk/extensions/OpenStackManager/OpenStackNovaProject.php (modified) (history)
  • /trunk/extensions/OpenStackManager/OpenStackNovaUser.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaAddress.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaDomain.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaKey.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaProject.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaPuppetGroup.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaRole.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaSecurityGroup.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaSudoer.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaVolume.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php
@@ -21,12 +21,12 @@
2222
2323 if ( ! $wgUser->isLoggedIn() ) {
2424 $this->notLoggedIn();
25 - return true;
 25+ return;
2626 }
2727 $this->userLDAP = new OpenStackNovaUser();
2828 if ( ! $this->userLDAP->exists() ) {
2929 $this->noCredentials();
30 - return true;
 30+ return;
3131 }
3232 $project = $wgRequest->getVal( 'project' );
3333 $userCredentials = $this->userLDAP->getCredentials();
@@ -39,31 +39,31 @@
4040 if ( $action == "create" ) {
4141 if ( ! $this->userLDAP->inProject( $project ) ) {
4242 $this->notInProject();
43 - return true;
 43+ return;
4444 }
4545 $this->createInstance();
4646 } elseif ( $action == "delete" ) {
4747 if ( ! $this->userLDAP->inProject( $project ) ) {
4848 $this->notInProject();
49 - return true;
 49+ return;
5050 }
5151 $this->deleteInstance();
5252 } elseif ( $action == "configure" ) {
5353 if ( ! $this->userLDAP->inProject( $project ) ) {
5454 $this->notInProject();
55 - return true;
 55+ return;
5656 }
5757 $this->configureInstance();
5858 } elseif ( $action == "reboot" ) {
5959 if ( ! $this->userLDAP->inProject( $project ) ) {
6060 $this->notInProject();
61 - return true;
 61+ return;
6262 }
6363 $this->rebootInstance();
6464 } elseif ( $action == "consoleoutput" ) {
6565 if ( ! $this->userLDAP->inProject( $project ) ) {
6666 $this->notInProject();
67 - return true;
 67+ return;
6868 }
6969 $this->getConsoleOutput();
7070 } else {
@@ -442,7 +442,7 @@
443443 $project = $wgRequest->getText( 'project' );
444444 if ( ! $this->userLDAP->inRole( 'sysadmin', $project ) ) {
445445 $this->notInRole( 'sysadmin' );
446 - return false;
 446+ return;
447447 }
448448 $instanceid = $wgRequest->getText( 'instanceid' );
449449 $consoleOutput = $this->userNova->getConsoleOutput( $instanceid );
Index: trunk/extensions/OpenStackManager/special/SpecialNovaSecurityGroup.php
@@ -19,14 +19,14 @@
2020 global $wgRequest, $wgUser;
2121 global $wgOpenStackManagerNovaAdminKeys;
2222
23 - if ( ! $wgUser->isLoggedIn() ) {
 23+ if ( !$wgUser->isLoggedIn() ) {
2424 $this->notLoggedIn();
25 - return true;
 25+ return;
2626 }
2727 $this->userLDAP = new OpenStackNovaUser();
2828 if ( ! $this->userLDAP->exists() ) {
2929 $this->noCredentials();
30 - return true;
 30+ return;
3131 }
3232 $adminCredentials = $wgOpenStackManagerNovaAdminKeys;
3333 $this->adminNova = new OpenStackNovaController( $adminCredentials );
Index: trunk/extensions/OpenStackManager/special/SpecialNovaAddress.php
@@ -17,14 +17,14 @@
1818 global $wgRequest, $wgUser;
1919 global $wgOpenStackManagerNovaAdminKeys;
2020
21 - if ( ! $wgUser->isLoggedIn() ) {
 21+ if ( !$wgUser->isLoggedIn() ) {
2222 $this->notLoggedIn();
23 - return false;
 23+ return;
2424 }
2525 $this->userLDAP = new OpenStackNovaUser();
26 - if ( ! $this->userLDAP->exists() ) {
 26+ if ( !$this->userLDAP->exists() ) {
2727 $this->noCredentials();
28 - return true;
 28+ return;
2929 }
3030 $adminCredentials = $wgOpenStackManagerNovaAdminKeys;
3131 $this->adminNova = new OpenStackNovaController( $adminCredentials );
Index: trunk/extensions/OpenStackManager/special/SpecialNovaProject.php
@@ -17,9 +17,9 @@
1818 function execute( $par ) {
1919 global $wgRequest, $wgUser;
2020
21 - if ( ! $wgUser->isLoggedIn() ) {
 21+ if ( !$wgUser->isLoggedIn() ) {
2222 $this->notLoggedIn();
23 - return false;
 23+ return;
2424 }
2525 $this->userLDAP = new OpenStackNovaUser();
2626 $action = $wgRequest->getVal( 'action' );
@@ -65,6 +65,7 @@
6666 'section' => 'project/membership',
6767 'name' => 'member',
6868 );
 69+ $role_keys = array();
6970 foreach ( OpenStackNovaProject::$rolenames as $rolename ) {
7071 $role_keys["$rolename"] = $rolename;
7172 }
Index: trunk/extensions/OpenStackManager/special/SpecialNovaDomain.php
@@ -17,28 +17,26 @@
1818 global $wgRequest, $wgUser;
1919 global $wgOpenStackManagerLDAPRolesIntersect;
2020
21 - if ( ! $wgUser->isLoggedIn() ) {
 21+ if ( !$wgUser->isLoggedIn() ) {
2222 $this->notLoggedIn();
23 - return false;
 23+ return;
2424 }
25 - if ( ! $this->userLDAP->exists() ) {
 25+ if ( !$this->userLDAP->exists() ) {
2626 $this->noCredentials();
27 - return false;
 27+ return;
2828 }
2929 # Must be in the global role
3030 if ( $wgOpenStackManagerLDAPRolesIntersect ) {
3131 # If roles intersect, we need to require cloudadmins, since
3232 # users are required to be in netadmins to manage project
3333 # specific netadmin things
34 - if ( ! $this->userLDAP->inGlobalRole( 'cloudadmin' ) ) {
 34+ if ( !$this->userLDAP->inGlobalRole( 'cloudadmin' ) ) {
3535 $this->notInRole( 'cloudadmin' );
36 - return false;
 36+ return;
3737 }
38 - } else {
39 - if ( ! $this->userLDAP->inGlobalRole( 'netadmin' ) ) {
40 - $this->notInRole( 'netadmin' );
41 - return false;
42 - }
 38+ } elseif ( !$this->userLDAP->inGlobalRole( 'netadmin' ) ) {
 39+ $this->notInRole( 'netadmin' );
 40+ return;
4341 }
4442
4543 $action = $wgRequest->getVal( 'action' );
Index: trunk/extensions/OpenStackManager/special/SpecialNovaVolume.php
@@ -19,14 +19,14 @@
2020 global $wgRequest, $wgUser;
2121 global $wgOpenStackManagerNovaAdminKeys;
2222
23 - if ( ! $wgUser->isLoggedIn() ) {
 23+ if ( !$wgUser->isLoggedIn() ) {
2424 $this->notLoggedIn();
25 - return true;
 25+ return;
2626 }
2727 $this->userLDAP = new OpenStackNovaUser();
28 - if ( ! $this->userLDAP->exists() ) {
 28+ if ( !$this->userLDAP->exists() ) {
2929 $this->noCredentials();
30 - return true;
 30+ return;
3131 }
3232 $project = $wgRequest->getVal( 'project' );
3333 $userCredentials = $this->userLDAP->getCredentials();
@@ -39,25 +39,25 @@
4040 if ( $action == "create" ) {
4141 if ( ! $this->userLDAP->inProject( $project ) ) {
4242 $this->notInProject();
43 - return true;
 43+ return;
4444 }
4545 $this->createVolume();
4646 } elseif ( $action == "delete" ) {
4747 if ( ! $this->userLDAP->inProject( $project ) ) {
4848 $this->notInProject();
49 - return true;
 49+ return;
5050 }
5151 $this->deleteVolume();
5252 } elseif ( $action == "attach" ) {
5353 if ( ! $this->userLDAP->inProject( $project ) ) {
5454 $this->notInProject();
55 - return true;
 55+ return;
5656 }
5757 $this->attachVolume();
5858 } elseif ( $action == "detach" ) {
5959 if ( ! $this->userLDAP->inProject( $project ) ) {
6060 $this->notInProject();
61 - return true;
 61+ return;
6262 }
6363 $this->detachVolume();
6464 } else {
Index: trunk/extensions/OpenStackManager/special/SpecialNovaKey.php
@@ -15,14 +15,14 @@
1616 function execute( $par ) {
1717 global $wgRequest, $wgUser;
1818
19 - if ( ! $wgUser->isLoggedIn() ) {
 19+ if ( !$wgUser->isLoggedIn() ) {
2020 $this->notLoggedIn();
21 - return true;
 21+ return;
2222 }
2323 $this->userLDAP = new OpenStackNovaUser();
24 - if ( ! $this->userLDAP->exists() ) {
 24+ if ( !$this->userLDAP->exists() ) {
2525 $this->noCredentials();
26 - return true;
 26+ return;
2727 }
2828
2929 $action = $wgRequest->getVal( 'action' );
@@ -47,7 +47,7 @@
4848 $project = $wgRequest->getVal( 'project' );
4949 if ( $project && ! $this->userLDAP->inProject( $project ) ) {
5050 $this->notInProject();
51 - return true;
 51+ return;
5252 }
5353 $userCredentials = $this->userLDAP->getCredentials();
5454 $this->userNova = new OpenStackNovaController( $userCredentials, $project );
Index: trunk/extensions/OpenStackManager/special/SpecialNovaPuppetGroup.php
@@ -10,7 +10,7 @@
1111
1212 if ( ! $wgUser->isLoggedIn() ) {
1313 $this->notLoggedIn();
14 - return false;
 14+ return;
1515 }
1616 $action = $wgRequest->getVal( 'action' );
1717 if ( $action == "create" ) {
Index: trunk/extensions/OpenStackManager/special/SpecialNovaRole.php
@@ -17,9 +17,9 @@
1818 function execute( $par ) {
1919 global $wgRequest, $wgUser;
2020
21 - if ( ! $wgUser->isLoggedIn() ) {
 21+ if ( !$wgUser->isLoggedIn() ) {
2222 $this->notLoggedIn();
23 - return false;
 23+ return;
2424 }
2525 $this->userLDAP = new OpenStackNovaUser();
2626 $action = $wgRequest->getVal( 'action' );
Index: trunk/extensions/OpenStackManager/special/SpecialNovaSudoer.php
@@ -12,13 +12,13 @@
1313 function execute( $par ) {
1414 global $wgRequest, $wgUser;
1515
16 - if ( ! $wgUser->isLoggedIn() ) {
 16+ if ( !$wgUser->isLoggedIn() ) {
1717 $this->notLoggedIn();
18 - return false;
 18+ return;
1919 }
20 - if ( ! $this->userLDAP->exists() ) {
 20+ if ( !$this->userLDAP->exists() ) {
2121 $this->noCredentials();
22 - return false;
 22+ return;
2323 }
2424
2525 $action = $wgRequest->getVal( 'action' );
Index: trunk/extensions/OpenStackManager/OpenStackNovaProject.php
@@ -137,7 +137,7 @@
138138 /**
139139 * Add a member to this project based on username
140140 *
141 - * @param $username string
 141+ * @param $username string
142142 * @return bool
143143 */
144144 function addMember( $username ) {
@@ -264,7 +264,6 @@
265265 * Deletes a project based on project name. This function will also delete all roles
266266 * associated with the project.
267267 *
268 - * @static
269268 * @param $projectname String
270269 * @return bool
271270 */
Index: trunk/extensions/OpenStackManager/OpenStackNovaHost.php
@@ -210,6 +210,7 @@
211211 return false;
212212 }
213213 }
 214+ return false;
214215 }
215216
216217 /**
Index: trunk/extensions/OpenStackManager/OpenStackNovaUser.php
@@ -247,9 +247,8 @@
248248 wfRestoreWarnings();
249249 return ( (int)$entries['count'] > 0 );
250250 }
251 - } else {
252 - return false;
253251 }
 252+ return false;
254253 }
255254
256255 /**
@@ -474,7 +473,6 @@
475474 */
476475 static function LDAPSetNovaInfo( $auth ) {
477476 OpenStackNovaLdapConnection::connect();
478 - $dn = $auth->userInfo[0]['dn'];
479477 wfSuppressWarnings();
480478 $result = ldap_read( $auth->ldapconn, $auth->userInfo[0]['dn'], '(objectclass=*)', array( 'secretkey', 'accesskey', 'objectclass' ) );
481479 $userInfo = ldap_get_entries( $auth->ldapconn, $result );

Status & tagging log