r113549 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113548‎ | r113549 | r113550 >
Date:23:53, 9 March 2012
Author:reedy
Status:ok
Tags:
Comment:
Code documentation

Some code simplification

Remove trailing whitespace

Remove someone unused variables
Modified paths:
  • /trunk/extensions/ExtensionDistributor/ExtensionDistributor_body.php (modified) (history)
  • /trunk/extensions/ExtensionDistributor/svn-invoker.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ExtensionDistributor/svn-invoker.php
@@ -20,13 +20,19 @@
2121
2222 svnExecute();
2323
 24+/**
 25+ * @param $s string
 26+ * @return bool
 27+ */
2428 function svnValidate( $s ) {
25 - if ( strpos( $s, '..' ) !== false ) {
26 - return false;
27 - }
28 - return true;
 29+ return strpos( $s, '..' ) === false;
2930 }
3031
 32+/**
 33+ * @param $cmd
 34+ * @param $retval
 35+ * @return string
 36+ */
3137 function svnShellExec( $cmd, &$retval ) {
3238 $retval = 1; // error by default?
3339 ob_start();
@@ -36,6 +42,10 @@
3743 return $output;
3844 }
3945
 46+/**
 47+ * @param $msg
 48+ * @param bool $info
 49+ */
4050 function svnError( $msg, $info = false ) {
4151 echo json_encode( array( 'error' => $msg, 'errorInfo' => $info ) );
4252 }
@@ -67,7 +77,6 @@
6878 }
6979 $timeout = 3;
7080 for ( $i = 0; $i < $timeout; $i++ ) {
71 - $wouldBlock = false;
7281 if ( flock( $lockFile, LOCK_EX | LOCK_NB ) ) {
7382 break;
7483 }
@@ -100,13 +109,13 @@
101110 if ( !$localRev ) {
102111 return;
103112 }
104 -
 113+
105114 // Determine last changed revision in the repo
106115 $remoteRev = svnGetRev( $remoteDir );
107116 if ( !$remoteRev ) {
108117 return;
109118 }
110 -
 119+
111120 if ( $remoteRev != $localRev ) {
112121 // Bad luck, we need to svn up
113122 $cmd = "svn up --non-interactive " . escapeshellarg( $dir ) . " 2>&1";
@@ -117,15 +126,19 @@
118127 return;
119128 }
120129 }
121 -
 130+
122131 echo json_encode( array( 'revision' => $remoteRev ) );
123132 }
124133
125 -// Returns the last changed revision or false
126 -// @param $dir Path or url of the folder
127 -// Output param $url Remote location of the folder
 134+/**
 135+ * Returns the last changed revision or false
 136+ *
 137+ * @param $dir string
 138+ * @param $url null|string Output param $url Remote location of the folder
 139+ * @return bool|string
 140+ */
128141 function svnGetRev( $dir, &$url = null ) {
129 -
 142+
130143 $cmd = "svn info --non-interactive --xml " . escapeshellarg( $dir );
131144 $retval = - 1;
132145 $result = svnShellExec( $cmd, $retval );
@@ -145,6 +158,6 @@
146159 svnError( 'extdist-svn-parse-error', $result );
147160 return false;
148161 }
149 -
 162+
150163 return $rev;
151164 }
Index: trunk/extensions/ExtensionDistributor/ExtensionDistributor_body.php
@@ -12,6 +12,9 @@
1313 parent::__construct( 'ExtensionDistributor' );
1414 }
1515
 16+ /**
 17+ * @param $subpage string
 18+ */
1619 public function execute( $subpage ) {
1720 global $wgExtDistTarDir, $wgExtDistWorkingCopy, $wgOut, $wgRequest;
1821
@@ -60,6 +63,9 @@
6164 $this->doDownload( $extension, $version );
6265 }
6366
 67+ /**
 68+ * @return bool
 69+ */
6470 protected function getExtensionList() {
6571 global $wgExtDistWorkingCopy, $wgExtDistBranches;
6672
@@ -101,6 +107,10 @@
102108 return $this->extensionList;
103109 }
104110
 111+ /**
 112+ * @param $path string
 113+ * @return bool|String
 114+ */
105115 protected function getBranchName( $path ) {
106116 global $wgExtDistBranches;
107117
@@ -150,6 +160,10 @@
151161 );
152162 }
153163
 164+ /**
 165+ * @param $extensionName string
 166+ * @return mixed
 167+ */
154168 protected function showVersionSelector( $extensionName ) {
155169 global $wgOut, $wgExtDistBranches;
156170
@@ -201,6 +215,10 @@
202216 );
203217 }
204218
 219+ /**
 220+ * @param $extension string
 221+ * @param $version string
 222+ */
205223 protected function doDownload( $extension, $version ) {
206224 global $wgExtDistWorkingCopy, $wgExtDistTarDir, $wgExtDistBranches,
207225 $wgOut, $wgExtDistTarUrl, $wgExtDistRemoteClient;
@@ -265,6 +283,11 @@
266284 header( 'Refresh: 5;url=' . $url );
267285 }
268286
 287+ /**
 288+ * @param $extension string
 289+ * @param $version string
 290+ * @return bool|string
 291+ */
269292 protected function updateAndGetRevisionLocal( $extension, $version ) {
270293 global $wgExtDistWorkingCopy, $wgOut;
271294
@@ -302,6 +325,11 @@
303326 return $rev;
304327 }
305328
 329+ /**
 330+ * @param $extension string
 331+ * @param $version string
 332+ * @return bool|string
 333+ */
306334 protected function updateAndGetRevisionRemote( $extension, $version ) {
307335 global $wgExtDistRemoteClient, $wgOut;
308336

Status & tagging log