Fixed spacing in actions/cache/filebackend/filerepo/job folder
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 20 Apr 2013 17:18:13 +0000 (19:18 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Sat, 20 Apr 2013 17:18:13 +0000 (19:18 +0200)
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Idb93d34e314e5f314223b79208968d6bcd30c40e

42 files changed:
includes/actions/CreditsAction.php
includes/actions/HistoryAction.php
includes/actions/InfoAction.php
includes/actions/PurgeAction.php
includes/actions/RawAction.php
includes/cache/BacklinkCache.php
includes/cache/CacheDependency.php
includes/cache/FileCacheBase.php
includes/cache/GenderCache.php
includes/cache/LinkBatch.php
includes/cache/LinkCache.php
includes/cache/MessageCache.php
includes/cache/SquidUpdate.php
includes/filebackend/FSFileBackend.php
includes/filebackend/FileBackend.php
includes/filebackend/FileBackendGroup.php
includes/filebackend/FileBackendStore.php
includes/filebackend/FileOp.php
includes/filebackend/SwiftFileBackend.php
includes/filebackend/filejournal/DBFileJournal.php
includes/filebackend/lockmanager/DBLockManager.php
includes/filebackend/lockmanager/LockManagerGroup.php
includes/filerepo/FSRepo.php
includes/filerepo/FileRepo.php
includes/filerepo/ForeignAPIRepo.php
includes/filerepo/ForeignDBRepo.php
includes/filerepo/LocalRepo.php
includes/filerepo/RepoGroup.php
includes/filerepo/file/ArchivedFile.php
includes/filerepo/file/File.php
includes/filerepo/file/ForeignAPIFile.php
includes/filerepo/file/LocalFile.php
includes/job/Job.php
includes/job/JobQueueAggregatorMemc.php
includes/job/JobQueueDB.php
includes/job/JobQueueFederated.php
includes/job/JobQueueRedis.php
includes/job/jobs/AssembleUploadChunksJob.php
includes/job/jobs/EnotifNotifyJob.php
includes/job/jobs/HTMLCacheUpdateJob.php
includes/job/jobs/PublishStashedFileJob.php
includes/job/jobs/RefreshLinksJob.php

index 895f3d3..0a2bf30 100644 (file)
@@ -114,9 +114,10 @@ class CreditsAction extends FormlessAction {
                # Hmm... too many to fit!
                if ( $cnt > 0 && $contributors->count() > $cnt ) {
                        $others_link = $this->othersLink();
-                       if ( !$showIfMax )
+                       if ( !$showIfMax ) {
                                return $this->msg( 'othercontribs' )->rawParams(
                                        $others_link )->params( $contributors->count() )->escaped();
+                       }
                }
 
                $real_names = array();
index 7296126..911fd58 100644 (file)
@@ -211,7 +211,7 @@ class HistoryAction extends FormlessAction {
         */
        function fetchRevisions( $limit, $offset, $direction ) {
                // Fail if article doesn't exist.
-               if( !$this->getTitle()->exists() ) {
+               if ( !$this->getTitle()->exists() ) {
                        return new FakeResultWrapper( array() );
                }
 
@@ -367,14 +367,14 @@ class HistoryPager extends ReverseChronologicalPager {
 
        function getQueryInfo() {
                $queryInfo = array(
-                       'tables'  => array( 'revision', 'user' ),
-                       'fields'  => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
-                       'conds'   => array_merge(
+                       'tables' => array( 'revision', 'user' ),
+                       'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
+                       'conds' => array_merge(
                                array( 'rev_page' => $this->getWikiPage()->getId() ),
                                $this->conds ),
                        'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
                        'join_conds' => array(
-                               'user'        => Revision::userJoinCond(),
+                               'user' => Revision::userJoinCond(),
                                'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
                );
                ChangeTags::modifyDisplayQuery(
@@ -413,10 +413,10 @@ class HistoryPager extends ReverseChronologicalPager {
                $batch = new LinkBatch();
                $revIds = array();
                foreach ( $this->mResult as $row ) {
-                       if( $row->rev_parent_id ) {
+                       if ( $row->rev_parent_id ) {
                                $revIds[] = $row->rev_parent_id;
                        }
-                       if( !is_null( $row->user_name ) ) {
+                       if ( !is_null( $row->user_name ) ) {
                                $batch->add( NS_USER, $row->user_name );
                                $batch->add( NS_USER_TALK, $row->user_name );
                        } else { # for anons or usernames of imported revisions
@@ -649,9 +649,9 @@ class HistoryPager extends ReverseChronologicalPager {
                                        $this->msg( 'editundo' )->escaped(),
                                        $undoTooltip,
                                        array(
-                                               'action'    => 'edit',
+                                               'action' => 'edit',
                                                'undoafter' => $prevRev->getId(),
-                                               'undo'      => $rev->getId()
+                                               'undo' => $rev->getId()
                                        )
                                );
                                $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
@@ -788,13 +788,13 @@ class HistoryPager extends ReverseChronologicalPager {
        function diffButtons( $rev, $firstInList ) {
                if ( $this->getNumRows() > 1 ) {
                        $id = $rev->getId();
-                       $radio = array( 'type'  => 'radio', 'value' => $id );
+                       $radio = array( 'type' => 'radio', 'value' => $id );
                        /** @todo: move title texts to javascript */
                        if ( $firstInList ) {
                                $first = Xml::element( 'input',
                                        array_merge( $radio, array(
                                                'style' => 'visibility:hidden',
-                                               'name'  => 'oldid',
+                                               'name' => 'oldid',
                                                'id' => 'mw-oldid-null' ) )
                                );
                                $checkmark = array( 'checked' => 'checked' );
@@ -811,13 +811,13 @@ class HistoryPager extends ReverseChronologicalPager {
                                }
                                $first = Xml::element( 'input',
                                        array_merge( $radio, $checkmark, array(
-                                               'name'  => 'oldid',
+                                               'name' => 'oldid',
                                                'id' => "mw-oldid-$id" ) ) );
                                $checkmark = array();
                        }
                        $second = Xml::element( 'input',
                                array_merge( $radio, $checkmark, array(
-                                       'name'  => 'diff',
+                                       'name' => 'diff',
                                        'id' => "mw-diff-$id" ) ) );
                        return $first . $second;
                } else {
index 55fa108..a8905d8 100644 (file)
@@ -602,7 +602,7 @@ class InfoAction extends FormlessAction {
                        'COUNT(*)',
                        array(
                                'wl_namespace' => $title->getNamespace(),
-                               'wl_title'     => $title->getDBkey(),
+                               'wl_title' => $title->getDBkey(),
                        ),
                        __METHOD__
                );
index 82cdc79..ed0bff7 100644 (file)
@@ -71,7 +71,7 @@ class PurgeAction extends FormAction {
                                $this->getRequest()->getQueryValues(),
                                array( 'title' => null, 'action' => null )
                        ) );
-                       if( $this->onSubmit( array() ) ) {
+                       if ( $this->onSubmit( array() ) ) {
                                $this->onSuccess();
                        }
                } else {
index 23db874..3fa20b7 100644 (file)
@@ -125,7 +125,7 @@ class RawAction extends FormlessAction {
                global $wgParser;
 
                # No longer used
-               if( $this->mGen ) {
+               if ( $this->mGen ) {
                        return '';
                }
 
@@ -194,14 +194,14 @@ class RawAction extends FormlessAction {
                switch ( $this->getRequest()->getText( 'direction' ) ) {
                        case 'next':
                                # output next revision, or nothing if there isn't one
-                               if( $oldid ) {
+                               if ( $oldid ) {
                                        $oldid = $this->getTitle()->getNextRevisionID( $oldid );
                                }
                                $oldid = $oldid ? $oldid : -1;
                                break;
                        case 'prev':
                                # output previous revision, or nothing if there isn't one
-                               if( !$oldid ) {
+                               if ( !$oldid ) {
                                        # get the current revision so we can get the penultimate one
                                        $oldid = $this->page->getLatest();
                                }
index d3e85d8..193f20f 100644 (file)
@@ -237,7 +237,7 @@ class BacklinkCache {
                } else {
                        $prefix = null;
                        wfRunHooks( 'BacklinkCacheGetPrefix', array( $table, &$prefix ) );
-                       if( $prefix ) {
+                       if ( $prefix ) {
                                return $prefix;
                        } else {
                                throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
@@ -292,7 +292,7 @@ class BacklinkCache {
                        default:
                                $conds = null;
                                wfRunHooks( 'BacklinkCacheGetConditions', array( $table, $this->title, &$conds ) );
-                               if( !$conds ) {
+                               if ( !$conds ) {
                                        throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
                                }
                }
index 0f047e8..32bcdf7 100644 (file)
@@ -404,7 +404,7 @@ class GlobalDependency extends CacheDependency {
         * @return bool
         */
        function isExpired() {
-               if( !isset( $GLOBALS[$this->name] ) ) {
+               if ( !isset( $GLOBALS[$this->name] ) ) {
                        return true;
                }
                return $GLOBALS[$this->name] != $this->value;
index 74feffb..7310f61 100644 (file)
@@ -138,7 +138,7 @@ abstract class FileCacheBase {
         * @return string
         */
        public function fetchText() {
-               if( $this->useGzip() ) {
+               if ( $this->useGzip() ) {
                        $fh = gzopen( $this->cachePath(), 'rb' );
                        return stream_get_contents( $fh );
                } else {
index 63e4226..b7d1b26 100644 (file)
@@ -66,15 +66,14 @@ class GenderCache {
        public function getGenderOf( $username, $caller = '' ) {
                global $wgUser;
 
-               if( $username instanceof User ) {
+               if ( $username instanceof User ) {
                        $username = $username->getName();
                }
 
                $username = self::normalizeUsername( $username );
                if ( !isset( $this->cache[$username] ) ) {
-
                        if ( $this->misses >= $this->missLimit && $wgUser->getName() !== $username ) {
-                               if( $this->misses === $this->missLimit ) {
+                               if ( $this->misses === $this->missLimit ) {
                                        $this->misses++;
                                        wfDebug( __METHOD__ . ": too many misses, returning default onwards\n" );
                                }
@@ -84,7 +83,6 @@ class GenderCache {
                                $this->misses++;
                                $this->doQuery( $username, $caller );
                        }
-
                }
 
                /* Undefined if there is a valid username which for some reason doesn't
@@ -102,7 +100,9 @@ class GenderCache {
        public function doLinkBatch( $data, $caller = '' ) {
                $users = array();
                foreach ( $data as $ns => $pagenames ) {
-                       if ( !MWNamespace::hasGenderDistinction( $ns ) ) continue;
+                       if ( !MWNamespace::hasGenderDistinction( $ns ) ) {
+                               continue;
+                       }
                        foreach ( array_keys( $pagenames ) as $username ) {
                                $users[$username] = true;
                        }
@@ -150,7 +150,7 @@ class GenderCache {
                                // For existing users, this value will be overwritten by the correct value
                                $this->cache[$name] = $default;
                                // query only for valid names, which can be in the database
-                               if( User::isValidUserName( $name ) ) {
+                               if ( User::isValidUserName( $name ) ) {
                                        $usersToCheck[] = $name;
                                }
                        }
index 72a2e8e..f47107c 100644 (file)
@@ -39,7 +39,7 @@ class LinkBatch {
        protected $caller;
 
        function __construct( $arr = array() ) {
-               foreach( $arr as $item ) {
+               foreach ( $arr as $item ) {
                        $this->addObj( $item );
                }
        }
index 0e41e26..31982e0 100644 (file)
@@ -156,8 +156,13 @@ class LinkCache {
                unset( $this->mGoodLinkFields[$dbkey] );
        }
 
-       public function getGoodLinks() { return $this->mGoodLinks; }
-       public function getBadLinks() { return array_keys( $this->mBadLinks ); }
+       public function getGoodLinks() {
+               return $this->mGoodLinks;
+       }
+
+       public function getBadLinks() {
+               return array_keys( $this->mBadLinks );
+       }
 
        /**
         * Add a title to the link cache, return the page_id or zero if non-existent
@@ -167,7 +172,7 @@ class LinkCache {
         */
        public function addLink( $title ) {
                $nt = Title::newFromDBkey( $title );
-               if( $nt ) {
+               if ( $nt ) {
                        return $this->addLinkObj( $nt );
                } else {
                        return 0;
@@ -215,7 +220,9 @@ class LinkCache {
                }
 
                $f = array( 'page_id', 'page_len', 'page_is_redirect', 'page_latest' );
-               if ( $wgContentHandlerUseDB ) $f[] = 'page_content_model';
+               if ( $wgContentHandlerUseDB ) {
+                       $f[] = 'page_content_model';
+               }
 
                $s = $db->selectRow( 'page', $f,
                        array( 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ),
index 6cc2a7e..49db857 100644 (file)
@@ -205,7 +205,7 @@ class MessageCache {
        function load( $code = false ) {
                global $wgUseLocalMessageCache;
 
-               if( !is_string( $code ) ) {
+               if ( !is_string( $code ) ) {
                        # This isn't really nice, so at least make a note about it and try to
                        # fall back
                        wfDebug( __METHOD__ . " called without providing a language code\n" );
index 5f5d257..dd71801 100644 (file)
@@ -125,7 +125,7 @@ class SquidUpdate {
        static function purge( $urlArr ) {
                global $wgSquidServers, $wgHTCPMulticastRouting;
 
-               if( !$urlArr ) {
+               if ( !$urlArr ) {
                        return;
                }
 
@@ -172,7 +172,7 @@ class SquidUpdate {
                $htcpOpCLR = 4; // HTCP CLR
 
                // @todo FIXME: PHP doesn't support these socket constants (include/linux/in.h)
-               if( !defined( "IPPROTO_IP" ) ) {
+               if ( !defined( "IPPROTO_IP" ) ) {
                        define( "IPPROTO_IP", 0 );
                        define( "IP_MULTICAST_LOOP", 34 );
                        define( "IP_MULTICAST_TTL", 33 );
@@ -183,13 +183,14 @@ class SquidUpdate {
                if ( $conn ) {
                        // Set socket options
                        socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_LOOP, 0 );
-                       if ( $wgHTCPMulticastTTL != 1 )
+                       if ( $wgHTCPMulticastTTL != 1 ) {
                                socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_TTL,
                                        $wgHTCPMulticastTTL );
+                       }
 
                        $urlArr = array_unique( $urlArr ); // Remove duplicates
                        foreach ( $urlArr as $url ) {
-                               if( !is_string( $url ) ) {
+                               if ( !is_string( $url ) ) {
                                        wfProfileOut( __METHOD__ );
                                        throw new MWException( 'Bad purge URL' );
                                }
index 92fee83..d4e32cf 100644 (file)
@@ -577,7 +577,7 @@ class FSFileBackend extends FileBackendStore {
                if ( $stat ) {
                        return array(
                                'mtime' => wfTimestamp( TS_MW, $stat['mtime'] ),
-                               'size'  => $stat['size']
+                               'size' => $stat['size']
                        );
                } elseif ( !$hadError ) {
                        return false; // file does not exist
@@ -862,7 +862,7 @@ abstract class FSFileBackendList implements Iterator {
         */
        public function __construct( $dir, array $params ) {
                $path = realpath( $dir ); // normalize
-               if( $path === false ) {
+               if ( $path === false ) {
                        $path = $dir;
                }
                $this->suffixStart = strlen( $path ) + 1; // size of "path/to/dir/"
@@ -963,7 +963,7 @@ abstract class FSFileBackendList implements Iterator {
         */
        protected function getRelPath( $dir ) {
                $path = realpath( $dir );
-               if( $path === false ) {
+               if ( $path === false ) {
                        $path = $dir;
                }
                return strtr( substr( $path, $this->suffixStart ), '\\', '/' );
index d505d6f..57fd4d7 100644 (file)
@@ -803,7 +803,9 @@ abstract class FileBackend {
        final protected function getScopedPHPBehaviorForOps() {
                if ( php_sapi_name() != 'cli' ) { // http://bugs.php.net/bug.php?id=47540
                        $old = ignore_user_abort( true ); // avoid half-finished operations
-                       return new ScopedCallback( function() use ( $old ) { ignore_user_abort( $old ); } );
+                       return new ScopedCallback( function() use ( $old ) {
+                               ignore_user_abort( $old );
+                       } );
                }
                return null;
        }
index d790a99..672e437 100644 (file)
@@ -95,17 +95,17 @@ class FileBackendGroup {
                                : 0644;
                        // Get the FS backend configuration
                        $autoBackends[] = array(
-                               'name'           => $backendName,
-                               'class'          => 'FSFileBackend',
-                               'lockManager'    => 'fsLockManager',
+                               'name' => $backendName,
+                               'class' => 'FSFileBackend',
+                               'lockManager' => 'fsLockManager',
                                'containerPaths' => array(
-                                       "{$repoName}-public"  => "{$directory}",
-                                       "{$repoName}-thumb"   => $thumbDir,
-                                       "{$repoName}-transcoded"   => $transcodedDir,
+                                       "{$repoName}-public" => "{$directory}",
+                                       "{$repoName}-thumb" => $thumbDir,
+                                       "{$repoName}-transcoded" => $transcodedDir,
                                        "{$repoName}-deleted" => $deletedDir,
-                                       "{$repoName}-temp"    => "{$directory}/temp"
+                                       "{$repoName}-temp" => "{$directory}/temp"
                                ),
-                               'fileMode'       => $fileMode,
+                               'fileMode' => $fileMode,
                        );
                }
 
@@ -135,8 +135,8 @@ class FileBackendGroup {
 
                        unset( $config['class'] ); // backend won't need this
                        $this->backends[$name] = array(
-                               'class'    => $class,
-                               'config'   => $config,
+                               'class' => $class,
+                               'config' => $config,
                                'instance' => null
                        );
                }
index 6d142b9..ea379bc 100644 (file)
@@ -1058,13 +1058,13 @@ abstract class FileBackendStore extends FileBackend {
         */
        final public function getOperationsInternal( array $ops ) {
                $supportedOps = array(
-                       'store'    => 'StoreFileOp',
-                       'copy'     => 'CopyFileOp',
-                       'move'     => 'MoveFileOp',
-                       'delete'   => 'DeleteFileOp',
-                       'create'   => 'CreateFileOp',
+                       'store' => 'StoreFileOp',
+                       'copy' => 'CopyFileOp',
+                       'move' => 'MoveFileOp',
+                       'delete' => 'DeleteFileOp',
+                       'create' => 'CreateFileOp',
                        'describe' => 'DescribeFileOp',
-                       'null'     => 'NullFileOp'
+                       'null' => 'NullFileOp'
                );
 
                $performOps = array(); // array of FileOp objects
index 62e9fba..80afcf2 100644 (file)
@@ -212,22 +212,22 @@ abstract class FileOp {
                $pathsUsed = array_merge( $this->storagePathsRead(), $this->storagePathsChanged() );
                foreach ( array_unique( $pathsUsed ) as $path ) {
                        $nullEntries[] = array( // assertion for recovery
-                               'op'      => 'null',
-                               'path'    => $path,
+                               'op' => 'null',
+                               'path' => $path,
                                'newSha1' => $this->fileSha1( $path, $oPredicates )
                        );
                }
                foreach ( $this->storagePathsChanged() as $path ) {
                        if ( $nPredicates['sha1'][$path] === false ) { // deleted
                                $deleteEntries[] = array(
-                                       'op'      => 'delete',
-                                       'path'    => $path,
+                                       'op' => 'delete',
+                                       'path' => $path,
                                        'newSha1' => ''
                                );
                        } else { // created/updated
                                $updateEntries[] = array(
-                                       'op'      => $this->fileExists( $path, $oPredicates ) ? 'update' : 'create',
-                                       'path'    => $path,
+                                       'op' => $this->fileExists( $path, $oPredicates ) ? 'update' : 'create',
+                                       'path' => $path,
                                        'newSha1' => $nPredicates['sha1'][$path]
                                );
                        }
index 00c0ff8..f0b289e 100644 (file)
@@ -807,8 +807,8 @@ class SwiftFileBackend extends FileBackendStore {
                        $stat = array(
                                // Convert dates like "Tue, 03 Jan 2012 22:01:04 GMT" to TS_MW
                                'mtime' => wfTimestamp( TS_MW, $srcObj->last_modified ),
-                               'size'  => (int)$srcObj->content_length,
-                               'sha1'  => $srcObj->getMetadataValue( 'Sha1base36' )
+                               'size' => (int)$srcObj->content_length,
+                               'sha1' => $srcObj->getMetadataValue( 'Sha1base36' )
                        );
                } catch ( NoSuchContainerException $e ) {
                } catch ( NoSuchObjectException $e ) {
@@ -1239,8 +1239,8 @@ class SwiftFileBackend extends FileBackendStore {
                                                str_replace( '/swift/v1', '', // S3 API is the rgw default
                                                        $sContObj->cfs_http->getStorageUrl() . $spath ),
                                                array(
-                                                       'Signature'      => $signature,
-                                                       'Expires'        => $expires,
+                                                       'Signature' => $signature,
+                                                       'Expires' => $expires,
                                                        'AWSAccessKeyId' => $this->rgwS3AccessKey )
                                        );
                                }
index 73f29a9..9250aa5 100644 (file)
@@ -65,11 +65,11 @@ class DBFileJournal extends FileJournal {
                foreach ( $entries as $entry ) {
                        $data[] = array(
                                'fj_batch_uuid' => $batchId,
-                               'fj_backend'    => $this->backend,
-                               'fj_op'         => $entry['op'],
-                               'fj_path'       => $entry['path'],
-                               'fj_new_sha1'   => $entry['newSha1'],
-                               'fj_timestamp'  => $dbw->timestamp( $now )
+                               'fj_backend' => $this->backend,
+                               'fj_op' => $entry['op'],
+                               'fj_path' => $entry['path'],
+                               'fj_new_sha1' => $entry['newSha1'],
+                               'fj_timestamp' => $dbw->timestamp( $now )
                        );
                }
 
index f02387d..e081987 100644 (file)
@@ -369,7 +369,9 @@ class PostgreSqlLockManager extends DBLockManager {
 
                $db = $this->getConnection( $lockSrv ); // checked in isServerUp()
                $bigints = array_unique( array_map(
-                       function( $key ) { return wfBaseConvert( substr( $key, 0, 15 ), 16, 10 ); },
+                       function( $key ) {
+                               return wfBaseConvert( substr( $key, 0, 15 ), 16, 10 );
+                       },
                        array_map( array( $this, 'sha1Base16Absolute' ), $paths )
                ) );
 
index ac0bd49..9aff241 100644 (file)
@@ -97,8 +97,8 @@ class LockManagerGroup {
                        $class = $config['class'];
                        unset( $config['class'] ); // lock manager won't need this
                        $this->managers[$name] = array(
-                               'class'    => $class,
-                               'config'   => $config,
+                               'class' => $class,
+                               'config' => $config,
                                'instance' => null
                        );
                }
index e49f37d..42c9c94 100644 (file)
@@ -56,16 +56,16 @@ class FSRepo extends FileRepo {
                        $repoName = $info['name'];
                        // Get the FS backend configuration
                        $backend = new FSFileBackend( array(
-                               'name'           => $info['name'] . '-backend',
-                               'lockManager'    => 'fsLockManager',
+                               'name' => $info['name'] . '-backend',
+                               'lockManager' => 'fsLockManager',
                                'containerPaths' => array(
-                                       "{$repoName}-public"  => "{$directory}",
-                                       "{$repoName}-temp"    => "{$directory}/temp",
-                                       "{$repoName}-thumb"   => $thumbDir,
-                                       "{$repoName}-transcoded"   => $transcodedDir,
+                                       "{$repoName}-public" => "{$directory}",
+                                       "{$repoName}-temp" => "{$directory}/temp",
+                                       "{$repoName}-thumb" => $thumbDir,
+                                       "{$repoName}-transcoded" => $transcodedDir,
                                        "{$repoName}-deleted" => $deletedDir
                                ),
-                               'fileMode'       => $fileMode,
+                               'fileMode' => $fileMode,
                        ) );
                        // Update repo config to use this backend
                        $info['backend'] = $backend;
index 0e30017..cfc3af7 100644 (file)
@@ -67,7 +67,7 @@ class FileRepo {
         */
        public function __construct( array $info = null ) {
                // Verify required settings presence
-               if(
+               if (
                        $info === null
                        || !array_key_exists( 'name', $info )
                        || !array_key_exists( 'backend', $info )
@@ -794,10 +794,10 @@ class FileRepo {
                                }
                        }
                        $operations[] = array(
-                               'op'            => $opName,
-                               'src'           => $srcPath,
-                               'dst'           => $dstPath,
-                               'overwrite'     => $flags & self::OVERWRITE,
+                               'op' => $opName,
+                               'src' => $srcPath,
+                               'dst' => $dstPath,
+                               'overwrite' => $flags & self::OVERWRITE,
                                'overwriteSame' => $flags & self::OVERWRITE_SAME,
                        );
                }
@@ -917,9 +917,9 @@ class FileRepo {
                        $src = $this->resolveToStoragePath( $src );
                        $dst = $this->resolveToStoragePath( $dst );
                        $operations[] = array(
-                               'op'          => FileBackend::isStoragePath( $src ) ? 'copy' : 'store',
-                               'src'         => $src,
-                               'dst'         => $dst,
+                               'op' => FileBackend::isStoragePath( $src ) ? 'copy' : 'store',
+                               'src' => $src,
+                               'dst' => $dst,
                                'disposition' => isset( $triple[2] ) ? $triple[2] : null
                        );
                        $status->merge( $this->initDirectory( dirname( $dst ) ) );
@@ -942,8 +942,8 @@ class FileRepo {
                $operations = array();
                foreach ( $paths as $path ) {
                        $operations[] = array(
-                               'op'                  => 'delete',
-                               'src'                 => $this->resolveToStoragePath( $path ),
+                               'op' => 'delete',
+                               'src' => $this->resolveToStoragePath( $path ),
                                'ignoreMissingSource' => true
                        );
                }
@@ -1132,9 +1132,9 @@ class FileRepo {
                        // race conditions unless an functioning LockManager is used.
                        // LocalFile also uses SELECT FOR UPDATE for synchronization.
                        $operations[] = array(
-                               'op'                  => 'copy',
-                               'src'                 => $dstPath,
-                               'dst'                 => $archivePath,
+                               'op' => 'copy',
+                               'src' => $dstPath,
+                               'dst' => $archivePath,
                                'ignoreMissingSource' => true
                        );
 
@@ -1142,28 +1142,28 @@ class FileRepo {
                        if ( FileBackend::isStoragePath( $srcPath ) ) {
                                if ( $flags & self::DELETE_SOURCE ) {
                                        $operations[] = array(
-                                               'op'        => 'move',
-                                               'src'       => $srcPath,
-                                               'dst'       => $dstPath,
+                                               'op' => 'move',
+                                               'src' => $srcPath,
+                                               'dst' => $dstPath,
                                                'overwrite' => true, // replace current
-                                               'headers'   => $headers
+                                               'headers' => $headers
                                        );
                                } else {
                                        $operations[] = array(
-                                               'op'        => 'copy',
-                                               'src'       => $srcPath,
-                                               'dst'       => $dstPath,
+                                               'op' => 'copy',
+                                               'src' => $srcPath,
+                                               'dst' => $dstPath,
                                                'overwrite' => true, // replace current
-                                               'headers'   => $headers
+                                               'headers' => $headers
                                        );
                                }
                        } else { // FS source path
                                $operations[] = array(
-                                       'op'        => 'store',
-                                       'src'       => $srcPath,
-                                       'dst'       => $dstPath,
+                                       'op' => 'store',
+                                       'src' => $srcPath,
+                                       'dst' => $dstPath,
                                        'overwrite' => true, // replace current
-                                       'headers'   => $headers
+                                       'headers' => $headers
                                );
                                if ( $flags & self::DELETE_SOURCE ) {
                                        $sourceFSFilesToDelete[] = $srcPath;
@@ -1324,9 +1324,9 @@ class FileRepo {
                        }
 
                        $operations[] = array(
-                               'op'            => 'move',
-                               'src'           => $srcPath,
-                               'dst'           => $archivePath,
+                               'op' => 'move',
+                               'src' => $srcPath,
+                               'dst' => $archivePath,
                                // We may have 2+ identical files being deleted,
                                // all of which will map to the same destination file
                                'overwriteSame' => true // also see bug 31792
@@ -1671,29 +1671,29 @@ class FileRepo {
         */
        public function getTempRepo() {
                return new TempFileRepo( array(
-                       'name'      => "{$this->name}-temp",
-                       'backend'   => $this->backend,
-                       'zones'     => array(
+                       'name' => "{$this->name}-temp",
+                       'backend' => $this->backend,
+                       'zones' => array(
                                'public' => array(
                                        'container' => $this->zones['temp']['container'],
                                        'directory' => $this->zones['temp']['directory']
                                ),
-                               'thumb'  => array(
+                               'thumb' => array(
                                        'container' => $this->zones['thumb']['container'],
                                        'directory' => ( $this->zones['thumb']['directory'] == '' )
                                                ? 'temp'
                                                : $this->zones['thumb']['directory'] . '/temp'
                                ),
-                               'transcoded'  => array(
+                               'transcoded' => array(
                                        'container' => $this->zones['transcoded']['container'],
                                        'directory' => ( $this->zones['transcoded']['directory'] == '' )
                                                ? 'temp'
                                                : $this->zones['transcoded']['directory'] . '/temp'
                                )
                        ),
-                       'url'        => $this->getZoneUrl( 'temp' ),
-                       'thumbUrl'   => $this->getZoneUrl( 'thumb' ) . '/temp',
-                       'transcodedUrl'   => $this->getZoneUrl( 'transcoded' ) . '/temp',
+                       'url' => $this->getZoneUrl( 'temp' ),
+                       'thumbUrl' => $this->getZoneUrl( 'thumb' ) . '/temp',
+                       'transcodedUrl' => $this->getZoneUrl( 'transcoded' ) . '/temp',
                        'hashLevels' => $this->hashLevels // performance
                ) );
        }
index ba574da..5cd6fc2 100644 (file)
@@ -61,21 +61,21 @@ class ForeignAPIRepo extends FileRepo {
                // http://commons.wikimedia.org/w/api.php
                $this->mApiBase = isset( $info['apibase'] ) ? $info['apibase'] : null;
 
-               if( isset( $info['apiThumbCacheExpiry'] ) ) {
+               if ( isset( $info['apiThumbCacheExpiry'] ) ) {
                        $this->apiThumbCacheExpiry = $info['apiThumbCacheExpiry'];
                }
-               if( isset( $info['fileCacheExpiry'] ) ) {
+               if ( isset( $info['fileCacheExpiry'] ) ) {
                        $this->fileCacheExpiry = $info['fileCacheExpiry'];
                }
-               if( !$this->scriptDirUrl ) {
+               if ( !$this->scriptDirUrl ) {
                        // hack for description fetches
                        $this->scriptDirUrl = dirname( $this->mApiBase );
                }
                // If we can cache thumbs we can guess sane defaults for these
-               if( $this->canCacheThumbs() && !$this->url ) {
+               if ( $this->canCacheThumbs() && !$this->url ) {
                        $this->url = $wgLocalFileRepo['url'];
                }
-               if( $this->canCacheThumbs() && !$this->thumbUrl ) {
+               if ( $this->canCacheThumbs() && !$this->thumbUrl ) {
                        $this->thumbUrl = $this->url . '/thumb';
                }
        }
@@ -105,7 +105,7 @@ class ForeignAPIRepo extends FileRepo {
                        if ( isset( $this->mFileExists[$k] ) ) {
                                $results[$k] = true;
                                unset( $files[$k] );
-                       } elseif( self::isVirtualUrl( $f ) ) {
+                       } elseif ( self::isVirtualUrl( $f ) ) {
                                # @todo FIXME: We need to be able to handle virtual
                                # URLs better, at least when we know they refer to the
                                # same repo.
@@ -120,9 +120,9 @@ class ForeignAPIRepo extends FileRepo {
 
                $data = $this->fetchImageQuery( array( 'titles' => implode( $files, '|' ),
                                                                                        'prop' => 'imageinfo' ) );
-               if( isset( $data['query']['pages'] ) ) {
+               if ( isset( $data['query']['pages'] ) ) {
                        $i = 0;
-                       foreach( $files as $key => $file ) {
+                       foreach ( $files as $key => $file ) {
                                $results[$key] = $this->mFileExists[$key] = !isset( $data['query']['pages'][$i]['missing'] );
                                $i++;
                        }
@@ -147,8 +147,8 @@ class ForeignAPIRepo extends FileRepo {
 
                $query = array_merge( $query,
                        array(
-                               'format'    => 'json',
-                               'action'    => 'query',
+                               'format' => 'json',
+                               'action' => 'query',
                                'redirects' => 'true'
                        ) );
                if ( $this->mApiBase ) {
@@ -157,10 +157,10 @@ class ForeignAPIRepo extends FileRepo {
                        $url = $this->makeUrl( $query, 'api' );
                }
 
-               if( !isset( $this->mQueryCache[$url] ) ) {
+               if ( !isset( $this->mQueryCache[$url] ) ) {
                        $key = $this->getLocalCacheKey( 'ForeignAPIRepo', 'Metadata', md5( $url ) );
                        $data = $wgMemc->get( $key );
-                       if( !$data ) {
+                       if ( !$data ) {
                                $data = self::httpGet( $url );
                                if ( !$data ) {
                                        return null;
@@ -168,7 +168,7 @@ class ForeignAPIRepo extends FileRepo {
                                $wgMemc->set( $key, $data, 3600 );
                        }
 
-                       if( count( $this->mQueryCache ) > 100 ) {
+                       if ( count( $this->mQueryCache ) > 100 ) {
                                // Keep the cache from growing infinitely
                                $this->mQueryCache = array();
                        }
@@ -182,9 +182,9 @@ class ForeignAPIRepo extends FileRepo {
         * @return bool|array
         */
        function getImageInfo( $data ) {
-               if( $data && isset( $data['query']['pages'] ) ) {
-                       foreach( $data['query']['pages'] as $info ) {
-                               if( isset( $info['imageinfo'][0] ) ) {
+               if ( $data && isset( $data['query']['pages'] ) ) {
+                       foreach ( $data['query']['pages'] as $info ) {
+                               if ( isset( $info['imageinfo'][0] ) ) {
                                        return $info['imageinfo'][0];
                                }
                        }
@@ -198,14 +198,15 @@ class ForeignAPIRepo extends FileRepo {
         */
        function findBySha1( $hash ) {
                $results = $this->fetchImageQuery( array(
-                                                                               'aisha1base36' => $hash,
-                                                                               'aiprop'       => ForeignAPIFile::getProps(),
-                                                                               'list'         => 'allimages', ) );
+                       'aisha1base36' => $hash,
+                       'aiprop' => ForeignAPIFile::getProps(),
+                       'list' => 'allimages',
+               ) );
                $ret = array();
                if ( isset( $results['query']['allimages'] ) ) {
                        foreach ( $results['query']['allimages'] as $img ) {
                                // 1.14 was broken, doesn't return name attribute
-                               if( !isset( $img['name'] ) ) {
+                               if ( !isset( $img['name'] ) ) {
                                        continue;
                                }
                                $ret[] = new ForeignAPIFile( Title::makeTitle( NS_FILE, $img['name'] ), $this, $img );
@@ -228,11 +229,11 @@ class ForeignAPIRepo extends FileRepo {
                        'iiprop' => 'url|timestamp',
                        'iiurlwidth' => $width,
                        'iiurlheight' => $height,
-                       'iiurlparam'  => $otherParams,
+                       'iiurlparam' => $otherParams,
                        'prop' => 'imageinfo' ) );
                $info = $this->getImageInfo( $data );
 
-               if( $data && $info && isset( $info['thumburl'] ) ) {
+               if ( $data && $info && isset( $info['thumburl'] ) ) {
                        wfDebug( __METHOD__ . " got remote thumb " . $info['thumburl'] . "\n" );
                        $result = $info;
                        return $info['thumburl'];
@@ -268,11 +269,11 @@ class ForeignAPIRepo extends FileRepo {
 
                /* Get the array of urls that we already know */
                $knownThumbUrls = $wgMemc->get( $key );
-               if( !$knownThumbUrls ) {
+               if ( !$knownThumbUrls ) {
                        /* No knownThumbUrls for this file */
                        $knownThumbUrls = array();
                } else {
-                       if( isset( $knownThumbUrls[$sizekey] ) ) {
+                       if ( isset( $knownThumbUrls[$sizekey] ) ) {
                                wfDebug( __METHOD__ . ': Got thumburl from local cache: ' .
                                        "{$knownThumbUrls[$sizekey]} \n" );
                                return $knownThumbUrls[$sizekey];
@@ -283,14 +284,14 @@ class ForeignAPIRepo extends FileRepo {
                $metadata = null;
                $foreignUrl = $this->getThumbUrl( $name, $width, $height, $metadata, $params );
 
-               if( !$foreignUrl ) {
+               if ( !$foreignUrl ) {
                        wfDebug( __METHOD__ . " Could not find thumburl\n" );
                        return false;
                }
 
                // We need the same filename as the remote one :)
                $fileName = rawurldecode( pathinfo( $foreignUrl, PATHINFO_BASENAME ) );
-               if( !$this->validateFilename( $fileName ) ) {
+               if ( !$this->validateFilename( $fileName ) ) {
                        wfDebug( __METHOD__ . " The deduced filename $fileName is not safe\n" );
                        return false;
                }
@@ -298,15 +299,14 @@ class ForeignAPIRepo extends FileRepo {
                $localFilename = $localPath . "/" . $fileName;
                $localUrl = $this->getZoneUrl( 'thumb' ) . "/" . $this->getHashPath( $name ) . rawurlencode( $name ) . "/" . rawurlencode( $fileName );
 
-               if( $backend->fileExists( array( 'src' => $localFilename ) )
-                       && isset( $metadata['timestamp'] ) )
-               {
+               if ( $backend->fileExists( array( 'src' => $localFilename ) )
+                       && isset( $metadata['timestamp'] ) ) {
                        wfDebug( __METHOD__ . " Thumbnail was already downloaded before\n" );
                        $modified = $backend->getFileTimestamp( array( 'src' => $localFilename ) );
                        $remoteModified = strtotime( $metadata['timestamp'] );
                        $current = time();
                        $diff = abs( $modified - $current );
-                       if( $remoteModified < $modified && $diff < $this->fileCacheExpiry ) {
+                       if ( $remoteModified < $modified && $diff < $this->fileCacheExpiry ) {
                                /* Use our current and already downloaded thumbnail */
                                $knownThumbUrls[$sizekey] = $localUrl;
                                $wgMemc->set( $key, $knownThumbUrls, $this->apiThumbCacheExpiry );
@@ -315,7 +315,7 @@ class ForeignAPIRepo extends FileRepo {
                        /* There is a new Commons file, or existing thumbnail older than a month */
                }
                $thumb = self::httpGet( $foreignUrl );
-               if( !$thumb ) {
+               if ( !$thumb ) {
                        wfDebug( __METHOD__ . " Could not download thumb\n" );
                        return false;
                }
@@ -323,7 +323,7 @@ class ForeignAPIRepo extends FileRepo {
                # @todo FIXME: Delete old thumbs that aren't being used. Maintenance script?
                $backend->prepare( array( 'dir' => dirname( $localFilename ) ) );
                $params = array( 'dst' => $localFilename, 'content' => $thumb );
-               if( !$backend->quickCreate( $params )->isOK() ) {
+               if ( !$backend->quickCreate( $params )->isOK() ) {
                        wfDebug( __METHOD__ . " could not write to thumb path '$localFilename'\n" );
                        return $foreignUrl;
                }
index 1865985..ecad618 100644 (file)
@@ -59,7 +59,7 @@ class ForeignDBRepo extends LocalRepo {
                        $this->dbConn = DatabaseBase::factory( $this->dbType,
                                array(
                                        'host' => $this->dbServer,
-                                       'user'   => $this->dbUser,
+                                       'user' => $this->dbUser,
                                        'password' => $this->dbPassword,
                                        'dbname' => $this->dbName,
                                        'flags' => $this->dbFlags,
index d017e13..549be40 100644 (file)
@@ -176,7 +176,7 @@ class LocalRepo extends FileRepo {
                } // else $cachedValue is false or null: cache miss
 
                $id = $this->getArticleID( $title );
-               if( !$id ) {
+               if ( !$id ) {
                        $wgMemc->set( $memcKey, " ", $expiry );
                        return false;
                }
@@ -188,7 +188,7 @@ class LocalRepo extends FileRepo {
                        __METHOD__
                );
 
-               if( $row && $row->rd_namespace == NS_FILE ) {
+               if ( $row && $row->rd_namespace == NS_FILE ) {
                        $targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title );
                        $wgMemc->set( $memcKey, $targetTitle->getDBkey(), $expiry );
                        return $targetTitle;
@@ -206,7 +206,7 @@ class LocalRepo extends FileRepo {
         * @return bool|int|mixed
         */
        protected function getArticleID( $title ) {
-               if( !$title instanceof Title ) {
+               if ( !$title instanceof Title ) {
                        return 0;
                }
                $dbr = $this->getSlaveDB();
@@ -258,7 +258,7 @@ class LocalRepo extends FileRepo {
         * @return array An Array of arrays or iterators of file objects and the hash as key
         */
        function findBySha1s( array $hashes ) {
-               if( !count( $hashes ) ) {
+               if ( !count( $hashes ) ) {
                        return array(); //empty parameter
                }
 
index 02dfdad..b2b9477 100644 (file)
@@ -209,7 +209,7 @@ class RepoGroup {
                }
 
                $redir = $this->localRepo->checkRedirect( $title );
-               if( $redir ) {
+               if ( $redir ) {
                        return $redir;
                }
                foreach ( $this->foreignRepos as $repo ) {
@@ -238,7 +238,9 @@ class RepoGroup {
                if ( !$file ) {
                        foreach ( $this->foreignRepos as $repo ) {
                                $file = $repo->findFileFromKey( $hash, $options );
-                               if ( $file ) break;
+                               if ( $file ) {
+                                       break;
+                               }
                        }
                }
                return $file;
@@ -279,7 +281,7 @@ class RepoGroup {
                        $result = array_merge_recursive( $result, $repo->findBySha1s( $hashes ) );
                }
                //sort the merged (and presorted) sublist of each hash
-               foreach( $result as $hash => $files ) {
+               foreach ( $result as $hash => $files ) {
                        usort( $result[$hash], 'File::compare' );
                }
                return $result;
@@ -339,9 +341,9 @@ class RepoGroup {
         * @return bool
         */
        function forEachForeignRepo( $callback, $params = array() ) {
-               foreach( $this->foreignRepos as $repo ) {
+               foreach ( $this->foreignRepos as $repo ) {
                        $args = array_merge( array( $repo ), $params );
-                       if( call_user_func_array( $callback, $args ) ) {
+                       if ( call_user_func_array( $callback, $args ) ) {
                                return true;
                        }
                }
index 3f78619..b753e18 100644 (file)
@@ -90,7 +90,7 @@ class ArchivedFile {
                $this->exists = false;
                $this->sha1 = '';
 
-               if( $title instanceof Title ) {
+               if ( $title instanceof Title ) {
                        $this->title = File::normalizeTitle( $title, 'exception' );
                        $this->name = $title->getDBkey();
                }
@@ -119,22 +119,22 @@ class ArchivedFile {
                }
                $conds = array();
 
-               if( $this->id > 0 ) {
+               if ( $this->id > 0 ) {
                        $conds['fa_id'] = $this->id;
                }
-               if( $this->key ) {
+               if ( $this->key ) {
                        $conds['fa_storage_group'] = $this->group;
                        $conds['fa_storage_key'] = $this->key;
                }
-               if( $this->title ) {
+               if ( $this->title ) {
                        $conds['fa_name'] = $this->title->getDBkey();
                }
 
-               if( !count( $conds ) ) {
+               if ( !count( $conds ) ) {
                        throw new MWException( "No specific information for retrieving archived file" );
                }
 
-               if( !$this->title || $this->title->getNamespace() == NS_FILE ) {
+               if ( !$this->title || $this->title->getNamespace() == NS_FILE ) {
                        $this->dataLoaded = true; // set it here, to have also true on miss
                        $dbr = wfGetDB( DB_SLAVE );
                        $row = $dbr->selectRow(
@@ -224,7 +224,7 @@ class ArchivedFile {
                $this->user_text = $row->fa_user_text;
                $this->timestamp = $row->fa_timestamp;
                $this->deleted = $row->fa_deleted;
-               if( isset( $row->fa_sha1 ) ) {
+               if ( isset( $row->fa_sha1 ) ) {
                        $this->sha1 = $row->fa_sha1;
                } else {
                        // old row, populate from key
@@ -409,7 +409,7 @@ class ArchivedFile {
         */
        public function getUser() {
                $this->load();
-               if( $this->isDeleted( File::DELETED_USER ) ) {
+               if ( $this->isDeleted( File::DELETED_USER ) ) {
                        return 0;
                } else {
                        return $this->user;
@@ -423,7 +423,7 @@ class ArchivedFile {
         */
        public function getUserText() {
                $this->load();
-               if( $this->isDeleted( File::DELETED_USER ) ) {
+               if ( $this->isDeleted( File::DELETED_USER ) ) {
                        return 0;
                } else {
                        return $this->user_text;
@@ -437,7 +437,7 @@ class ArchivedFile {
         */
        public function getDescription() {
                $this->load();
-               if( $this->isDeleted( File::DELETED_COMMENT ) ) {
+               if ( $this->isDeleted( File::DELETED_COMMENT ) ) {
                        return 0;
                } else {
                        return $this->description;
index 255da17..0da4036 100644 (file)
@@ -201,9 +201,9 @@ abstract class File {
                        'mpeg' => 'mpg',
                        'tiff' => 'tif',
                        'ogv' => 'ogg' );
-               if( isset( $squish[$lower] ) ) {
+               if ( isset( $squish[$lower] ) ) {
                        return $squish[$lower];
-               } elseif( preg_match( '/^[0-9a-z]+$/', $lower ) ) {
+               } elseif ( preg_match( '/^[0-9a-z]+$/', $lower ) ) {
                        return $lower;
                } else {
                        return '';
@@ -241,7 +241,7 @@ abstract class File {
         * @return array ("text", "html") etc
         */
        public static function splitMime( $mime ) {
-               if( strpos( $mime, '/' ) !== false ) {
+               if ( strpos( $mime, '/' ) !== false ) {
                        return explode( '/', $mime, 2 );
                } else {
                        return array( $mime, 'unknown' );
index edf623e..61d321e 100644 (file)
@@ -54,22 +54,22 @@ class ForeignAPIFile extends File {
         */
        static function newFromTitle( Title $title, $repo ) {
                $data = $repo->fetchImageQuery( array(
-                       'titles'            => 'File:' . $title->getDBkey(),
-                       'iiprop'            => self::getProps(),
-                       'prop'              => 'imageinfo',
+                       'titles' => 'File:' . $title->getDBkey(),
+                       'iiprop' => self::getProps(),
+                       'prop' => 'imageinfo',
                        'iimetadataversion' => MediaHandler::getMetadataVersion()
                ) );
 
                $info = $repo->getImageInfo( $data );
 
-               if( $info ) {
+               if ( $info ) {
                        $lastRedirect = isset( $data['query']['redirects'] )
                                ? count( $data['query']['redirects'] ) - 1
                                : -1;
-                       if( $lastRedirect >= 0 ) {
+                       if ( $lastRedirect >= 0 ) {
                                $newtitle = Title::newFromText( $data['query']['redirects'][$lastRedirect]['to'] );
                                $img = new self( $newtitle, $repo, $info, true );
-                               if( $img ) {
+                               if ( $img ) {
                                        $img->redirectedFrom( $title->getDBkey() );
                                }
                        } else {
@@ -111,7 +111,7 @@ class ForeignAPIFile extends File {
         * @return bool|MediaTransformOutput
         */
        function transform( $params, $flags = 0 ) {
-               if( !$this->canRender() ) {
+               if ( !$this->canRender() ) {
                        // show icon
                        return parent::transform( $params, $flags );
                }
@@ -161,11 +161,11 @@ class ForeignAPIFile extends File {
         * @return array
         */
        public static function parseMetadata( $metadata ) {
-               if( !is_array( $metadata ) ) {
+               if ( !is_array( $metadata ) ) {
                        return $metadata;
                }
                $ret = array();
-               foreach( $metadata as $meta ) {
+               foreach ( $metadata as $meta ) {
                        $ret[$meta['name']] = self::parseMetadata( $meta['value'] );
                }
                return $ret;
@@ -224,7 +224,7 @@ class ForeignAPIFile extends File {
         * @return string
         */
        function getMimeType() {
-               if( !isset( $this->mInfo['mime'] ) ) {
+               if ( !isset( $this->mInfo['mime'] ) ) {
                        $magic = MimeMagic::singleton();
                        $this->mInfo['mime'] = $magic->guessTypesForExtension( $this->getExtension() );
                }
index b481e83..8bd8376 100644 (file)
@@ -532,15 +532,15 @@ class LocalFile extends File {
 
                $dbw->update( 'image',
                        array(
-                               'img_size'       => $this->size, // sanity
-                               'img_width'      => $this->width,
-                               'img_height'     => $this->height,
-                               'img_bits'       => $this->bits,
+                               'img_size' => $this->size, // sanity
+                               'img_width' => $this->width,
+                               'img_height' => $this->height,
+                               'img_bits' => $this->bits,
                                'img_media_type' => $this->media_type,
                                'img_major_mime' => $major,
                                'img_minor_mime' => $minor,
-                               'img_metadata'   => $this->metadata,
-                               'img_sha1'       => $this->sha1,
+                               'img_metadata' => $this->metadata,
+                               'img_sha1' => $this->sha1,
                        ),
                        array( 'img_name' => $this->getName() ),
                        __METHOD__
@@ -803,7 +803,7 @@ class LocalFile extends File {
                $oldKey = $this->repo->getSharedCacheKey( 'oldfile', $hashedName );
 
                // Must purge thumbnails for old versions too! bug 30192
-               foreach( $this->getHistory() as $oldFile ) {
+               foreach ( $this->getHistory() as $oldFile ) {
                        $oldFile->purgeThumbnails();
                }
 
@@ -845,7 +845,7 @@ class LocalFile extends File {
                // Purge the squid
                if ( $wgUseSquid ) {
                        $urls = array();
-                       foreach( $files as $file ) {
+                       foreach ( $files as $file ) {
                                $urls[] = $this->getArchiveThumbUrl( $archiveName, $file );
                        }
                        SquidUpdate::purge( $urls );
@@ -866,7 +866,7 @@ class LocalFile extends File {
                // Always purge all files from squid regardless of handler filters
                if ( $wgUseSquid ) {
                        $urls = array();
-                       foreach( $files as $file ) {
+                       foreach ( $files as $file ) {
                                $urls[] = $this->getThumbUrl( $file );
                        }
                        array_shift( $urls ); // don't purge directory
@@ -1196,20 +1196,20 @@ class LocalFile extends File {
                # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
                $dbw->insert( 'image',
                        array(
-                               'img_name'        => $this->getName(),
-                               'img_size'        => $this->size,
-                               'img_width'       => intval( $this->width ),
-                               'img_height'      => intval( $this->height ),
-                               'img_bits'        => $this->bits,
-                               'img_media_type'  => $this->media_type,
-                               'img_major_mime'  => $this->major_mime,
-                               'img_minor_mime'  => $this->minor_mime,
-                               'img_timestamp'   => $timestamp,
+                               'img_name' => $this->getName(),
+                               'img_size' => $this->size,
+                               'img_width' => intval( $this->width ),
+                               'img_height' => intval( $this->height ),
+                               'img_bits' => $this->bits,
+                               'img_media_type' => $this->media_type,
+                               'img_major_mime' => $this->major_mime,
+                               'img_minor_mime' => $this->minor_mime,
+                               'img_timestamp' => $timestamp,
                                'img_description' => $comment,
-                               'img_user'        => $user->getId(),
-                               'img_user_text'   => $user->getName(),
-                               'img_metadata'    => $this->metadata,
-                               'img_sha1'        => $this->sha1
+                               'img_user' => $user->getId(),
+                               'img_user_text' => $user->getName(),
+                               'img_metadata' => $this->metadata,
+                               'img_sha1' => $this->sha1
                        ),
                        __METHOD__,
                        'IGNORE'
@@ -1602,9 +1602,13 @@ class LocalFile extends File {
         */
        function getDescriptionText() {
                $revision = Revision::newFromTitle( $this->title, false, Revision::READ_NORMAL );
-               if ( !$revision ) return false;
+               if ( !$revision ) {
+                       return false;
+               }
                $content = $revision->getContent();
-               if ( !$content ) return false;
+               if ( !$content ) {
+                       return false;
+               }
                $pout = $content->getParserOutput( $this->title, null, new ParserOptions() );
                return $pout->getText();
        }
@@ -2174,7 +2178,7 @@ class LocalFileRestoreBatch {
                        $deletedRel = $this->file->repo->getDeletedHashPath( $row->fa_storage_key ) . $row->fa_storage_key;
                        $deletedUrl = $this->file->repo->getVirtualUrl() . '/deleted/' . $deletedRel;
 
-                       if( isset( $row->fa_sha1 ) ) {
+                       if ( isset( $row->fa_sha1 ) ) {
                                $sha1 = $row->fa_sha1;
                        } else {
                                // old row, populate from key
index a765d5d..bb6fb04 100644 (file)
@@ -68,7 +68,7 @@ abstract class Job {
         */
        public static function factory( $command, Title $title, $params = false, $id = 0 ) {
                global $wgJobClasses;
-               if( isset( $wgJobClasses[$command] ) ) {
+               if ( isset( $wgJobClasses[$command] ) ) {
                        $class = $wgJobClasses[$command];
                        return new $class( $title, $params, $id );
                }
@@ -213,10 +213,10 @@ abstract class Job {
         */
        public function getDeduplicationInfo() {
                $info = array(
-                       'type'      => $this->getType(),
+                       'type' => $this->getType(),
                        'namespace' => $this->getTitle()->getNamespace(),
-                       'title'     => $this->getTitle()->getDBkey(),
-                       'params'    => $this->getParams()
+                       'title' => $this->getTitle()->getDBkey(),
+                       'params' => $this->getParams()
                );
                if ( is_array( $info['params'] ) ) {
                        // Identical jobs with different "root" jobs should count as duplicates
index c364209..9434da0 100644 (file)
@@ -91,7 +91,7 @@ class JobQueueAggregatorMemc extends JobQueueAggregator {
                        if ( $this->cache->add( "$key:rebuild", 1, 1800 ) ) { // lock
                                $pendingDbInfo = array(
                                        'pendingDBs' => $this->findPendingWikiQueues(),
-                                       'timestamp'  => time()
+                                       'timestamp' => time()
                                );
                                for ( $attempts = 1; $attempts <= 25; ++$attempts ) {
                                        if ( $this->cache->add( "$key:lock", 1, 60 ) ) { // lock
index a685fe3..e8e0385 100644 (file)
@@ -225,7 +225,7 @@ class JobQueueDB extends JobQueue {
                                $res = $dbw->select( 'job', 'job_sha1',
                                        array(
                                                // No job_type condition since it's part of the job_sha1 hash
-                                               'job_sha1'  => array_keys( $rowSet ),
+                                               'job_sha1' => array_keys( $rowSet ),
                                                'job_token' => '' // unclaimed
                                        ),
                                        $method
@@ -300,7 +300,7 @@ class JobQueueDB extends JobQueue {
                        $job->metadata['id'] = $row->job_id;
                        $job->id = $row->job_id; // XXX: work around broken subclasses
                        break; // done
-               } while( true );
+               } while ( true );
 
                return $job;
        }
@@ -332,7 +332,7 @@ class JobQueueDB extends JobQueue {
                                $dir = $gte ? 'ASC' : 'DESC';
                                $row = $dbw->selectRow( 'job', '*', // find a random job
                                        array(
-                                               'job_cmd'   => $this->type,
+                                               'job_cmd' => $this->type,
                                                'job_token' => '', // unclaimed
                                                "job_random {$ineq} {$dbw->addQuotes( $rand )}" ),
                                        __METHOD__,
@@ -349,7 +349,7 @@ class JobQueueDB extends JobQueue {
                                // instead of job_random for reducing excess claim retries.
                                $row = $dbw->selectRow( 'job', '*', // find a random job
                                        array(
-                                               'job_cmd'   => $this->type,
+                                               'job_cmd' => $this->type,
                                                'job_token' => '', // unclaimed
                                        ),
                                        __METHOD__,
@@ -364,7 +364,7 @@ class JobQueueDB extends JobQueue {
                        if ( $row ) { // claim the job
                                $dbw->update( 'job', // update by PK
                                        array(
-                                               'job_token'           => $uuid,
+                                               'job_token' => $uuid,
                                                'job_token_timestamp' => $dbw->timestamp(),
                                                'job_attempts = job_attempts+1' ),
                                        array( 'job_cmd' => $this->type, 'job_id' => $row->job_id, 'job_token' => '' ),
@@ -415,7 +415,7 @@ class JobQueueDB extends JobQueue {
                                // This uses as much of the DB wrapper functions as possible.
                                $dbw->update( 'job',
                                        array(
-                                               'job_token'           => $uuid,
+                                               'job_token' => $uuid,
                                                'job_token_timestamp' => $dbw->timestamp(),
                                                'job_attempts = job_attempts+1' ),
                                        array( 'job_id = (' .
@@ -514,7 +514,7 @@ class JobQueueDB extends JobQueue {
                return array(
                        'recycleAndDeleteStaleJobs' => array(
                                'callback' => array( $this, 'recycleAndDeleteStaleJobs' ),
-                               'period'   => ceil( $this->claimTTL / 2 )
+                               'period' => ceil( $this->claimTTL / 2 )
                        )
                );
        }
@@ -578,7 +578,11 @@ class JobQueueDB extends JobQueue {
                                        "job_attempts < {$dbw->addQuotes( $this->maxTries )}" ), // retries left
                                __METHOD__
                        );
-                       $ids = array_map( function( $o ) { return $o->job_id; }, iterator_to_array( $res ) );
+                       $ids = array_map(
+                               function( $o ) {
+                                       return $o->job_id;
+                               }, iterator_to_array( $res )
+                       );
                        if ( count( $ids ) ) {
                                // Reset job_token for these jobs so that other runners will pick them up.
                                // Set the timestamp to the current time, as it is useful to now that the job
@@ -610,7 +614,11 @@ class JobQueueDB extends JobQueue {
                // Get the IDs of jobs that are considered stale and should be removed. Selecting
                // the IDs first means that the UPDATE can be done by primary key (less deadlocks).
                $res = $dbw->select( 'job', 'job_id', $conds, __METHOD__ );
-               $ids = array_map( function( $o ) { return $o->job_id; }, iterator_to_array( $res ) );
+               $ids = array_map(
+                       function( $o ) {
+                               return $o->job_id;
+                       }, iterator_to_array( $res )
+               );
                if ( count( $ids ) ) {
                        $dbw->delete( 'job', array( 'job_id' => $ids ), __METHOD__ );
                        $count += $dbw->affectedRows();
index ed3c4f4..7a5d113 100644 (file)
@@ -61,7 +61,7 @@ class JobQueueFederated extends JobQueue {
        protected $cache;
 
        const CACHE_TTL_SHORT = 30; // integer; seconds to cache info without re-validating
-       const CACHE_TTL_LONG  = 300; // integer; seconds to cache info that is kept up to date
+       const CACHE_TTL_LONG = 300; // integer; seconds to cache info that is kept up to date
 
        /**
         * @params include:
index f14f9fa..249ba27 100644 (file)
@@ -667,13 +667,13 @@ LUA;
                if ( $this->claimTTL > 0 ) {
                        $tasks['recycleAndDeleteStaleJobs'] = array(
                                'callback' => array( $this, 'recycleAndDeleteStaleJobs' ),
-                               'period'   => ceil( $this->claimTTL / 2 )
+                               'period' => ceil( $this->claimTTL / 2 )
                        );
                }
                if ( $this->checkDelay ) {
                        $tasks['releaseReadyDelayedJobs'] = array(
                                'callback' => array( $this, 'releaseReadyDelayedJobs' ),
-                               'period'   => 300 // 5 minutes
+                               'period' => 300 // 5 minutes
                        );
                }
                return $tasks;
index c5dd9ea..4fe1753 100644 (file)
@@ -82,11 +82,11 @@ class AssembleUploadChunksJob extends Job {
                        UploadBase::setSessionStatus(
                                $this->params['filekey'],
                                array(
-                                       'result'    => 'Success',
-                                       'stage'     => 'assembling',
-                                       'filekey'   => $newFileKey,
+                                       'result' => 'Success',
+                                       'stage' => 'assembling',
+                                       'filekey' => $newFileKey,
                                        'imageinfo' => $imageInfo,
-                                       'status'    => Status::newGood()
+                                       'status' => Status::newGood()
                                )
                        );
                } catch ( MWException $e ) {
@@ -94,7 +94,7 @@ class AssembleUploadChunksJob extends Job {
                                $this->params['filekey'],
                                array(
                                        'result' => 'Failure',
-                                       'stage'  => 'assembling',
+                                       'stage' => 'assembling',
                                        'status' => Status::newFatal( 'api-error-stashfailed' )
                                )
                        );
index 2be05b6..bbe988d 100644 (file)
@@ -35,7 +35,7 @@ class EnotifNotifyJob extends Job {
        function run() {
                $enotif = new EmailNotification();
                // Get the user from ID (rename safe). Anons are 0, so defer to name.
-               if( isset( $this->params['editorID'] ) && $this->params['editorID'] ) {
+               if ( isset( $this->params['editorID'] ) && $this->params['editorID'] ) {
                        $editor = User::newFromId( $this->params['editorID'] );
                // B/C, only the name might be given.
                } else {
index 376b388..44c240b 100644 (file)
@@ -154,7 +154,7 @@ class HTMLCacheUpdateJob extends Job {
                                        array(
                                                'table' => $this->params['table'],
                                                'start' => $start,
-                                               'end'   => $id - 1
+                                               'end' => $id - 1
                                        ) + $rootJobParams // carry over information for de-duplication
                                );
                                $start = $id;
@@ -167,7 +167,7 @@ class HTMLCacheUpdateJob extends Job {
                        array(
                                'table' => $this->params['table'],
                                'start' => $start,
-                               'end'   => $this->params['end']
+                               'end' => $this->params['end']
                        ) + $rootJobParams // carry over information for de-duplication
                );
                wfDebug( __METHOD__ . ": repartitioning into " . count( $jobs ) . " jobs\n" );
@@ -203,7 +203,7 @@ class HTMLCacheUpdateJob extends Job {
                                array(
                                        'table' => $this->params['table'],
                                        'start' => $start,
-                                       'end'   => $end,
+                                       'end' => $end,
                                ) + $rootJobParams // carry over information for de-duplication
                        );
                }
@@ -254,7 +254,7 @@ class HTMLCacheUpdateJob extends Job {
                }
 
                # Update file cache
-               if  ( $wgUseFileCache ) {
+               if ( $wgUseFileCache ) {
                        foreach ( $titleArray as $title ) {
                                HTMLFileCache::clearFileCache( $title );
                        }
index d3feda2..625e8aa 100644 (file)
@@ -94,11 +94,11 @@ class PublishStashedFileJob extends Job {
                        UploadBase::setSessionStatus(
                                $this->params['filekey'],
                                array(
-                                       'result'    => 'Success',
-                                       'stage'     => 'publish',
-                                       'filename'  => $upload->getLocalFile()->getName(),
+                                       'result' => 'Success',
+                                       'stage' => 'publish',
+                                       'filename' => $upload->getLocalFile()->getName(),
                                        'imageinfo' => $imageInfo,
-                                       'status'    => Status::newGood()
+                                       'status' => Status::newGood()
                                )
                        );
                } catch ( MWException $e ) {
@@ -106,7 +106,7 @@ class PublishStashedFileJob extends Job {
                                $this->params['filekey'],
                                array(
                                        'result' => 'Failure',
-                                       'stage'  => 'publish',
+                                       'stage' => 'publish',
                                        'status' => Status::newFatal( 'api-error-publishfailed' )
                                )
                        );
index 261ae63..4a5ecfc 100644 (file)
@@ -159,10 +159,10 @@ class RefreshLinksJob2 extends Job {
                                        list( $start, $end ) = $batch;
                                        $jobs[] = new RefreshLinksJob2( $this->title,
                                                array(
-                                                       'table'            => $table,
-                                                       'start'            => $start,
-                                                       'end'              => $end,
-                                                       'masterPos'        => $masterPos,
+                                                       'table' => $table,
+                                                       'start' => $start,
+                                                       'end' => $end,
+                                                       'masterPos' => $masterPos,
                                                ) + $this->getRootJobParams() // carry over information for de-duplication
                                        );
                                }