Index: trunk/extensions/ExtensionDistributor/svn-invoker.php |
— | — | @@ -20,13 +20,19 @@ |
21 | 21 | |
22 | 22 | svnExecute(); |
23 | 23 | |
| 24 | +/** |
| 25 | + * @param $s string |
| 26 | + * @return bool |
| 27 | + */ |
24 | 28 | function svnValidate( $s ) { |
25 | | - if ( strpos( $s, '..' ) !== false ) { |
26 | | - return false; |
27 | | - } |
28 | | - return true; |
| 29 | + return strpos( $s, '..' ) === false; |
29 | 30 | } |
30 | 31 | |
| 32 | +/** |
| 33 | + * @param $cmd |
| 34 | + * @param $retval |
| 35 | + * @return string |
| 36 | + */ |
31 | 37 | function svnShellExec( $cmd, &$retval ) { |
32 | 38 | $retval = 1; // error by default? |
33 | 39 | ob_start(); |
— | — | @@ -36,6 +42,10 @@ |
37 | 43 | return $output; |
38 | 44 | } |
39 | 45 | |
| 46 | +/** |
| 47 | + * @param $msg |
| 48 | + * @param bool $info |
| 49 | + */ |
40 | 50 | function svnError( $msg, $info = false ) { |
41 | 51 | echo json_encode( array( 'error' => $msg, 'errorInfo' => $info ) ); |
42 | 52 | } |
— | — | @@ -67,7 +77,6 @@ |
68 | 78 | } |
69 | 79 | $timeout = 3; |
70 | 80 | for ( $i = 0; $i < $timeout; $i++ ) { |
71 | | - $wouldBlock = false; |
72 | 81 | if ( flock( $lockFile, LOCK_EX | LOCK_NB ) ) { |
73 | 82 | break; |
74 | 83 | } |
— | — | @@ -100,13 +109,13 @@ |
101 | 110 | if ( !$localRev ) { |
102 | 111 | return; |
103 | 112 | } |
104 | | - |
| 113 | + |
105 | 114 | // Determine last changed revision in the repo |
106 | 115 | $remoteRev = svnGetRev( $remoteDir ); |
107 | 116 | if ( !$remoteRev ) { |
108 | 117 | return; |
109 | 118 | } |
110 | | - |
| 119 | + |
111 | 120 | if ( $remoteRev != $localRev ) { |
112 | 121 | // Bad luck, we need to svn up |
113 | 122 | $cmd = "svn up --non-interactive " . escapeshellarg( $dir ) . " 2>&1"; |
— | — | @@ -117,15 +126,19 @@ |
118 | 127 | return; |
119 | 128 | } |
120 | 129 | } |
121 | | - |
| 130 | + |
122 | 131 | echo json_encode( array( 'revision' => $remoteRev ) ); |
123 | 132 | } |
124 | 133 | |
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 | + */ |
128 | 141 | function svnGetRev( $dir, &$url = null ) { |
129 | | - |
| 142 | + |
130 | 143 | $cmd = "svn info --non-interactive --xml " . escapeshellarg( $dir ); |
131 | 144 | $retval = - 1; |
132 | 145 | $result = svnShellExec( $cmd, $retval ); |
— | — | @@ -145,6 +158,6 @@ |
146 | 159 | svnError( 'extdist-svn-parse-error', $result ); |
147 | 160 | return false; |
148 | 161 | } |
149 | | - |
| 162 | + |
150 | 163 | return $rev; |
151 | 164 | } |
Index: trunk/extensions/ExtensionDistributor/ExtensionDistributor_body.php |
— | — | @@ -12,6 +12,9 @@ |
13 | 13 | parent::__construct( 'ExtensionDistributor' ); |
14 | 14 | } |
15 | 15 | |
| 16 | + /** |
| 17 | + * @param $subpage string |
| 18 | + */ |
16 | 19 | public function execute( $subpage ) { |
17 | 20 | global $wgExtDistTarDir, $wgExtDistWorkingCopy, $wgOut, $wgRequest; |
18 | 21 | |
— | — | @@ -60,6 +63,9 @@ |
61 | 64 | $this->doDownload( $extension, $version ); |
62 | 65 | } |
63 | 66 | |
| 67 | + /** |
| 68 | + * @return bool |
| 69 | + */ |
64 | 70 | protected function getExtensionList() { |
65 | 71 | global $wgExtDistWorkingCopy, $wgExtDistBranches; |
66 | 72 | |
— | — | @@ -101,6 +107,10 @@ |
102 | 108 | return $this->extensionList; |
103 | 109 | } |
104 | 110 | |
| 111 | + /** |
| 112 | + * @param $path string |
| 113 | + * @return bool|String |
| 114 | + */ |
105 | 115 | protected function getBranchName( $path ) { |
106 | 116 | global $wgExtDistBranches; |
107 | 117 | |
— | — | @@ -150,6 +160,10 @@ |
151 | 161 | ); |
152 | 162 | } |
153 | 163 | |
| 164 | + /** |
| 165 | + * @param $extensionName string |
| 166 | + * @return mixed |
| 167 | + */ |
154 | 168 | protected function showVersionSelector( $extensionName ) { |
155 | 169 | global $wgOut, $wgExtDistBranches; |
156 | 170 | |
— | — | @@ -201,6 +215,10 @@ |
202 | 216 | ); |
203 | 217 | } |
204 | 218 | |
| 219 | + /** |
| 220 | + * @param $extension string |
| 221 | + * @param $version string |
| 222 | + */ |
205 | 223 | protected function doDownload( $extension, $version ) { |
206 | 224 | global $wgExtDistWorkingCopy, $wgExtDistTarDir, $wgExtDistBranches, |
207 | 225 | $wgOut, $wgExtDistTarUrl, $wgExtDistRemoteClient; |
— | — | @@ -265,6 +283,11 @@ |
266 | 284 | header( 'Refresh: 5;url=' . $url ); |
267 | 285 | } |
268 | 286 | |
| 287 | + /** |
| 288 | + * @param $extension string |
| 289 | + * @param $version string |
| 290 | + * @return bool|string |
| 291 | + */ |
269 | 292 | protected function updateAndGetRevisionLocal( $extension, $version ) { |
270 | 293 | global $wgExtDistWorkingCopy, $wgOut; |
271 | 294 | |
— | — | @@ -302,6 +325,11 @@ |
303 | 326 | return $rev; |
304 | 327 | } |
305 | 328 | |
| 329 | + /** |
| 330 | + * @param $extension string |
| 331 | + * @param $version string |
| 332 | + * @return bool|string |
| 333 | + */ |
306 | 334 | protected function updateAndGetRevisionRemote( $extension, $version ) { |
307 | 335 | global $wgExtDistRemoteClient, $wgOut; |
308 | 336 | |