r108455 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108454‎ | r108455 | r108456 >
Date:18:46, 9 January 2012
Author:reedy
Status:ok
Tags:
Comment:
Fix mixed tabs and spaces
Modified paths:
  • /trunk/extensions/WindowsAzureStorage/WindowsAzureStorage.php (modified) (history)
  • /trunk/extensions/WindowsAzureStorage/includes/filerepo/backend/WindowsAzureFileBackend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WindowsAzureStorage/includes/filerepo/backend/WindowsAzureFileBackend.php
@@ -27,23 +27,23 @@
2828 function doStore( array $p ) {
2929 return $this->doStoreInternal( $p );
3030 }
31 -
 31+
3232 function doCopy( array $p ) {
3333 return $this->doCopyInternal( $p );
3434 }
35 -
 35+
3636 function doDelete( array $p ) {
3737 return $this->doDeleteInternal( $p );
3838 }
39 -
 39+
4040 function doConcatenate( array $p ) {
4141 return $this->dodoConcatenateInternal( $p );
4242 }
43 -
 43+
4444 function doCreate( array $p ) {
4545 return $this->doCreateInternal( $p );
4646 }
47 -
 47+
4848 /**
4949 * @see FileBackend::move()
5050 */
@@ -60,13 +60,13 @@
6161 $status->setResult( true, $status->value ); // ignore delete() errors
6262 return $status;
6363 }
64 -
 64+
6565 /** @var Microsoft_WindowsAzure_Storage_Blob */
6666 protected $storageClient = null;
6767
68 - /** @var Array Map of container names to Azure container names */
 68+ /** @var Array Map of container names to Azure container names */
6969 protected $containerPaths = array();
70 -
 70+
7171 /**
7272 * @see FileBackend::__construct()
7373 * Additional $config params include:
@@ -74,7 +74,7 @@
7575 * azureAccount : Windows Azure user used by MediaWiki
7676 * azureKey : Authentication key for the above user (used to get sessions)
7777 * //azureContainer : Identifier of the container. (Optional. If not provided wikiId will be used as container name)
78 - * containerPaths : Map of container names to Azure container names
 78+ * containerPaths : Map of container names to Azure container names
7979 */
8080 public function __construct( array $config ) {
8181 parent::__construct( $config );
@@ -84,14 +84,14 @@
8585 $config['azureKey']
8686 );
8787
88 - $this->containerPaths = (array)$config['containerPaths'];
 88+ $this->containerPaths = (array)$config['containerPaths'];
8989 }
9090
9191 /**
9292 * @see FileBackend::resolveContainerPath()
9393 */
9494 protected function resolveContainerPath( $container, $relStoragePath ) {
95 - //Azure container naming conventions; http://msdn.microsoft.com/en-us/library/dd135715.aspx
 95+ //Azure container naming conventions; http://msdn.microsoft.com/en-us/library/dd135715.aspx
9696
9797 if ( strlen( urlencode( $relStoragePath ) ) > 1024 ) {
9898 return null;
@@ -150,11 +150,11 @@
151151
152152 // (a) Check the source container
153153 try { //TODO: Unnecessary --> remove
154 - $container = $this->storageClient->getContainer( $srcCont );
 154+ $container = $this->storageClient->getContainer( $srcCont );
155155 }
156 - catch ( Exception $e ) {
 156+ catch ( Exception $e ) {
157157 // TODO: remove error_log
158 - error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
 158+ error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
159159 $status->fatal( 'backend-fail-internal' );
160160 return $status;
161161 }
@@ -163,8 +163,8 @@
164164 try {
165165 $this->storageClient->deleteBlob( $srcCont, $srcRel );
166166 }
167 - catch ( Exception $e ) {
168 - error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
 167+ catch ( Exception $e ) {
 168+ error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
169169 $status->fatal( 'backend-fail-internal' );
170170 }
171171
@@ -184,19 +184,19 @@
185185 }
186186
187187 // (a) Check if the destination object already exists
188 - $blobExists = $this->storageClient->blobExists( $dstCont, $dstRel );
189 - if ( $blobExists && empty( $params['overwriteDest'] ) ) { //Blob exists _and_ should not be overridden
190 - $status->fatal( 'backend-fail-alreadyexists', $params['dst'] );
191 - return $status;
192 - }
 188+ $blobExists = $this->storageClient->blobExists( $dstCont, $dstRel );
 189+ if ( $blobExists && empty( $params['overwriteDest'] ) ) { //Blob exists _and_ should not be overridden
 190+ $status->fatal( 'backend-fail-alreadyexists', $params['dst'] );
 191+ return $status;
 192+ }
193193
194194 // (b) Actually create the object
195195 try {
196196 // TODO: how do I know the container exists? Should we call prepare?
197 - $this->storageClient->putBlobData( $dstCont, $dstRel, $params['content'] );
 197+ $this->storageClient->putBlobData( $dstCont, $dstRel, $params['content'] );
198198 }
199 - catch ( Exception $e ) {
200 - error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
 199+ catch ( Exception $e ) {
 200+ error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
201201 $status->fatal( 'backend-fail-internal' );
202202 }
203203
@@ -209,36 +209,36 @@
210210 function prepare( array $params ) {
211211 $status = Status::newGood();
212212
213 - list( $c, $dir ) = $this->resolveStoragePath( $params['dir'] );
 213+ list( $c, $dir ) = $this->resolveStoragePath( $params['dir'] );
214214 if ( $dir === null ) {
215215 $status->fatal( 'backend-fail-invalidpath', $params['dir'] );
216216 return $status; // invalid storage path
217217 }
218 - try {
219 - $this->storageClient->createContainerIfNotExists( $c );
220 - $this->storageClient->setContainerAcl( $c, Microsoft_WindowsAzure_Storage_Blob::ACL_PUBLIC );//TODO: Really set public?
 218+ try {
 219+ $this->storageClient->createContainerIfNotExists( $c );
 220+ $this->storageClient->setContainerAcl( $c, Microsoft_WindowsAzure_Storage_Blob::ACL_PUBLIC );//TODO: Really set public?
221221
222 - //TODO: check if readable and writeable
223 - //$container = $this->storageClient->getContainer( $c );
224 - //$status->fatal( 'directoryreadonlyerror', $params['dir'] );
225 - //$status->fatal( 'directorynotreadableerror', $params['dir'] );
226 - }
227 - catch (Exception $e ) {
228 - $status->fatal( 'directorycreateerror', $params['dir'] );
 222+ //TODO: check if readable and writeable
 223+ //$container = $this->storageClient->getContainer( $c );
 224+ //$status->fatal( 'directoryreadonlyerror', $params['dir'] );
 225+ //$status->fatal( 'directorynotreadableerror', $params['dir'] );
 226+ }
 227+ catch (Exception $e ) {
 228+ $status->fatal( 'directorycreateerror', $params['dir'] );
229229 return $status;
230 - }
 230+ }
231231 return $status;
232232 }
233 -
234 - /**
 233+
 234+ /**
235235 * @see FileBackend::resolveContainerName()
236236 */
237 - protected function resolveContainerName( $container ) {
238 - //Azure container naming conventions; http://msdn.microsoft.com/en-us/library/dd135715.aspx
239 - $container = strtolower($container);
240 - $container = preg_replace( '#[^a-z0-9\-]#', '', $container );
 237+ protected function resolveContainerName( $container ) {
 238+ //Azure container naming conventions; http://msdn.microsoft.com/en-us/library/dd135715.aspx
 239+ $container = strtolower($container);
 240+ $container = preg_replace( '#[^a-z0-9\-]#', '', $container );
241241 // TODO: -test und test- geht auch nicht
242 - $container = preg_replace( '#-{2,}#', '-', $container );
 242+ $container = preg_replace( '#-{2,}#', '-', $container );
243243
244244 return $container;
245245 }
@@ -256,7 +256,7 @@
257257 * @see FileBackend::fileExists()
258258 */
259259 function fileExists( array $params ) {
260 - list( $c, $dir ) = $this->resolveStoragePath( $params['src'] );
 260+ list( $c, $dir ) = $this->resolveStoragePath( $params['src'] );
261261 // TODO: null? Telling names
262262 $exists = $this->storageClient->blobExists( $c, $dir );
263263 //error_log( __METHOD__.'::blobExists - result: '.$exists );
@@ -272,38 +272,38 @@
273273 return false; // invalid storage path
274274 }
275275
276 - $timestamp= false;
 276+ $timestamp= false;
277277 try {
278 - //TODO Maybe use getBlobData()?
279 - $blob = $this->storageClient->getBlobInstance( $srcCont, $srcRel );
280 - $timestamp = wfTimestamp( TS_MW, $blob->lastmodified ); //TODO: Timezone?
 278+ //TODO Maybe use getBlobData()?
 279+ $blob = $this->storageClient->getBlobInstance( $srcCont, $srcRel );
 280+ $timestamp = wfTimestamp( TS_MW, $blob->lastmodified ); //TODO: Timezone?
281281 } catch ( Exception $e ) { // some other exception?
282 - error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
 282+ error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
283283 }
284 - return $timestamp;
 284+ return $timestamp;
285285 }
286286
287287 /**
288288 * @see FileBackend::getFileList()
289289 */
290290 function getFileList( array $params ) {
291 - $files = array();
 291+ $files = array();
292292 list( $c, $dir ) = $this->resolveStoragePath( $params['dir'] );
293 - try {
294 - if ( $dir === null ) {
295 - $blobs = $this->storageClient->listBlobs($c);
296 - }
297 - else {
298 - $blobs = $this->storageClient->listBlobs( $c, $dir );//TODO:Check if $dir really is a startsequence of the blob name
299 - }
300 - foreach( $blobs as $blob ) {
301 - $files[] = $blob->name;
302 - }
303 - }
304 - catch( Exception $e ) {
305 - error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
306 - return null;
307 - }
 293+ try {
 294+ if ( $dir === null ) {
 295+ $blobs = $this->storageClient->listBlobs($c);
 296+ }
 297+ else {
 298+ $blobs = $this->storageClient->listBlobs( $c, $dir );//TODO:Check if $dir really is a startsequence of the blob name
 299+ }
 300+ foreach( $blobs as $blob ) {
 301+ $files[] = $blob->name;
 302+ }
 303+ }
 304+ catch( Exception $e ) {
 305+ error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
 306+ return null;
 307+ }
308308
309309 // if there are no files matching the prefix, return empty array
310310 return $files;
@@ -329,10 +329,10 @@
330330 $tmpPath = $tmpFile->getPath();
331331
332332 try {
333 - $this->storageClient->getBlob( $srcCont, $srcRel, $tmpPath );
 333+ $this->storageClient->getBlob( $srcCont, $srcRel, $tmpPath );
334334 }
335 - catch ( Exception $e ) {
336 - error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
 335+ catch ( Exception $e ) {
 336+ error_log( __METHOD__.':'.__LINE__.' '.$e->getMessage() );
337337 $tmpFile = null;
338338 }
339339
Index: trunk/extensions/WindowsAzureStorage/WindowsAzureStorage.php
@@ -1,7 +1,7 @@
22 <?php
33 /*
44 (c) Hallo Welt! Medienwerkstatt GmbH, 2011 GPL
5 -
 5+
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
88 the Free Software Foundation; either version 2 of the License, or
@@ -39,21 +39,21 @@
4040
4141 /* Those are just development values. You may override them or specify your own backend definition in LocalSettings.php */
4242 $wgFileBackends[] = array(
43 - 'name' => 'azure-backend',
44 - 'class' => 'WindowsAzureFileBackend',
45 - //'wikiId' => 'some_unique_ID',
46 - 'lockManager' => 'nullLockManager',
47 - 'azureHost' => 'http://127.0.0.1:10000',
48 - 'azureAccount' => 'devstoreaccount1',
49 - 'azureKey' => 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',
50 - //'azureContainer' => 'developcontainer',
51 -
52 - //IMPORTANT: Mind the container naming conventions! http://msdn.microsoft.com/en-us/library/dd135715.aspx
53 - 'containerPaths' => array(
54 - 'media-public' => 'media-public',
55 - 'media-thumb' => 'media-thumb',
56 - 'media-deleted' => 'media-deleted',
57 - 'media-temp' => 'media-temp',
 43+ 'name' => 'azure-backend',
 44+ 'class' => 'WindowsAzureFileBackend',
 45+ //'wikiId' => 'some_unique_ID',
 46+ 'lockManager' => 'nullLockManager',
 47+ 'azureHost' => 'http://127.0.0.1:10000',
 48+ 'azureAccount' => 'devstoreaccount1',
 49+ 'azureKey' => 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',
 50+ //'azureContainer' => 'developcontainer',
5851
59 - )
60 -);
\ No newline at end of file
 52+ //IMPORTANT: Mind the container naming conventions! http://msdn.microsoft.com/en-us/library/dd135715.aspx
 53+ 'containerPaths' => array(
 54+ 'media-public' => 'media-public',
 55+ 'media-thumb' => 'media-thumb',
 56+ 'media-deleted' => 'media-deleted',
 57+ 'media-temp' => 'media-temp',
 58+
 59+ )
 60+);

Status & tagging log