From: umherirrender Date: Sat, 20 Apr 2013 17:18:13 +0000 (+0200) Subject: Fixed spacing in actions/cache/filebackend/filerepo/job folder X-Git-Tag: 1.31.0-rc.0~19930 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=1bfc8feb25b564cc35ae1142271518a0c964f98d;p=lhc%2Fweb%2Fwiklou.git Fixed spacing in actions/cache/filebackend/filerepo/job folder Added spaces before if, foreach Added some braces for one line statements Change-Id: Idb93d34e314e5f314223b79208968d6bcd30c40e --- diff --git a/includes/actions/CreditsAction.php b/includes/actions/CreditsAction.php index 895f3d3822..0a2bf30686 100644 --- a/includes/actions/CreditsAction.php +++ b/includes/actions/CreditsAction.php @@ -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(); diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index 72961264a5..911fd58a62 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -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[] = "{$undolink}"; @@ -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 { diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 55fa108fe7..a8905d82fa 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -602,7 +602,7 @@ class InfoAction extends FormlessAction { 'COUNT(*)', array( 'wl_namespace' => $title->getNamespace(), - 'wl_title' => $title->getDBkey(), + 'wl_title' => $title->getDBkey(), ), __METHOD__ ); diff --git a/includes/actions/PurgeAction.php b/includes/actions/PurgeAction.php index 82cdc79ac9..ed0bff7b97 100644 --- a/includes/actions/PurgeAction.php +++ b/includes/actions/PurgeAction.php @@ -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 { diff --git a/includes/actions/RawAction.php b/includes/actions/RawAction.php index 23db874262..3fa20b70e5 100644 --- a/includes/actions/RawAction.php +++ b/includes/actions/RawAction.php @@ -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(); } diff --git a/includes/cache/BacklinkCache.php b/includes/cache/BacklinkCache.php index d3e85d8694..193f20fee8 100644 --- a/includes/cache/BacklinkCache.php +++ b/includes/cache/BacklinkCache.php @@ -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__ ); } } diff --git a/includes/cache/CacheDependency.php b/includes/cache/CacheDependency.php index 0f047e80af..32bcdf7f4f 100644 --- a/includes/cache/CacheDependency.php +++ b/includes/cache/CacheDependency.php @@ -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; diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php index 74feffb123..7310f61518 100644 --- a/includes/cache/FileCacheBase.php +++ b/includes/cache/FileCacheBase.php @@ -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 { diff --git a/includes/cache/GenderCache.php b/includes/cache/GenderCache.php index 63e4226da4..b7d1b26116 100644 --- a/includes/cache/GenderCache.php +++ b/includes/cache/GenderCache.php @@ -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; } } diff --git a/includes/cache/LinkBatch.php b/includes/cache/LinkBatch.php index 72a2e8e5ae..f47107c68f 100644 --- a/includes/cache/LinkBatch.php +++ b/includes/cache/LinkBatch.php @@ -39,7 +39,7 @@ class LinkBatch { protected $caller; function __construct( $arr = array() ) { - foreach( $arr as $item ) { + foreach ( $arr as $item ) { $this->addObj( $item ); } } diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php index 0e41e265b1..31982e0b11 100644 --- a/includes/cache/LinkCache.php +++ b/includes/cache/LinkCache.php @@ -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() ), diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 6cc2a7e5bd..49db8576d3 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -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" ); diff --git a/includes/cache/SquidUpdate.php b/includes/cache/SquidUpdate.php index 5f5d25714f..dd7180173a 100644 --- a/includes/cache/SquidUpdate.php +++ b/includes/cache/SquidUpdate.php @@ -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' ); } diff --git a/includes/filebackend/FSFileBackend.php b/includes/filebackend/FSFileBackend.php index 92fee8350b..d4e32cf1ae 100644 --- a/includes/filebackend/FSFileBackend.php +++ b/includes/filebackend/FSFileBackend.php @@ -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 ), '\\', '/' ); diff --git a/includes/filebackend/FileBackend.php b/includes/filebackend/FileBackend.php index d505d6fa88..57fd4d7775 100644 --- a/includes/filebackend/FileBackend.php +++ b/includes/filebackend/FileBackend.php @@ -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; } diff --git a/includes/filebackend/FileBackendGroup.php b/includes/filebackend/FileBackendGroup.php index d790a99601..672e437a36 100644 --- a/includes/filebackend/FileBackendGroup.php +++ b/includes/filebackend/FileBackendGroup.php @@ -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 ); } diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php index 6d142b9828..ea379bc911 100644 --- a/includes/filebackend/FileBackendStore.php +++ b/includes/filebackend/FileBackendStore.php @@ -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 diff --git a/includes/filebackend/FileOp.php b/includes/filebackend/FileOp.php index 62e9fbada6..80afcf226e 100644 --- a/includes/filebackend/FileOp.php +++ b/includes/filebackend/FileOp.php @@ -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] ); } diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 00c0ff825c..f0b289e13b 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -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 ) ); } diff --git a/includes/filebackend/filejournal/DBFileJournal.php b/includes/filebackend/filejournal/DBFileJournal.php index 73f29a9549..9250aa5e01 100644 --- a/includes/filebackend/filejournal/DBFileJournal.php +++ b/includes/filebackend/filejournal/DBFileJournal.php @@ -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 ) ); } diff --git a/includes/filebackend/lockmanager/DBLockManager.php b/includes/filebackend/lockmanager/DBLockManager.php index f02387dc5b..e081987851 100644 --- a/includes/filebackend/lockmanager/DBLockManager.php +++ b/includes/filebackend/lockmanager/DBLockManager.php @@ -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 ) ) ); diff --git a/includes/filebackend/lockmanager/LockManagerGroup.php b/includes/filebackend/lockmanager/LockManagerGroup.php index ac0bd49bf9..9aff241528 100644 --- a/includes/filebackend/lockmanager/LockManagerGroup.php +++ b/includes/filebackend/lockmanager/LockManagerGroup.php @@ -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 ); } diff --git a/includes/filerepo/FSRepo.php b/includes/filerepo/FSRepo.php index e49f37d280..42c9c94535 100644 --- a/includes/filerepo/FSRepo.php +++ b/includes/filerepo/FSRepo.php @@ -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; diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 0e30017581..cfc3af7f6f 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -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 ) ); } diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index ba574da177..5cd6fc2873 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -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; } diff --git a/includes/filerepo/ForeignDBRepo.php b/includes/filerepo/ForeignDBRepo.php index 18659852d2..ecad618b5a 100644 --- a/includes/filerepo/ForeignDBRepo.php +++ b/includes/filerepo/ForeignDBRepo.php @@ -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, diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index d017e1351c..549be40807 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -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 } diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php index 02dfdad6a6..b2b9477ab3 100644 --- a/includes/filerepo/RepoGroup.php +++ b/includes/filerepo/RepoGroup.php @@ -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; } } diff --git a/includes/filerepo/file/ArchivedFile.php b/includes/filerepo/file/ArchivedFile.php index 3f78619758..b753e18a25 100644 --- a/includes/filerepo/file/ArchivedFile.php +++ b/includes/filerepo/file/ArchivedFile.php @@ -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; diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 255da179ce..0da4036ac1 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -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' ); diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php index edf623e281..61d321ea15 100644 --- a/includes/filerepo/file/ForeignAPIFile.php +++ b/includes/filerepo/file/ForeignAPIFile.php @@ -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() ); } diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index b481e83b0d..8bd83769bc 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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 diff --git a/includes/job/Job.php b/includes/job/Job.php index a765d5d429..bb6fb0479f 100644 --- a/includes/job/Job.php +++ b/includes/job/Job.php @@ -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 diff --git a/includes/job/JobQueueAggregatorMemc.php b/includes/job/JobQueueAggregatorMemc.php index c364209541..9434da0459 100644 --- a/includes/job/JobQueueAggregatorMemc.php +++ b/includes/job/JobQueueAggregatorMemc.php @@ -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 diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php index a685fe3505..e8e03852af 100644 --- a/includes/job/JobQueueDB.php +++ b/includes/job/JobQueueDB.php @@ -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(); diff --git a/includes/job/JobQueueFederated.php b/includes/job/JobQueueFederated.php index ed3c4f45db..7a5d11330d 100644 --- a/includes/job/JobQueueFederated.php +++ b/includes/job/JobQueueFederated.php @@ -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: diff --git a/includes/job/JobQueueRedis.php b/includes/job/JobQueueRedis.php index f14f9fa733..249ba27724 100644 --- a/includes/job/JobQueueRedis.php +++ b/includes/job/JobQueueRedis.php @@ -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; diff --git a/includes/job/jobs/AssembleUploadChunksJob.php b/includes/job/jobs/AssembleUploadChunksJob.php index c5dd9eaa4d..4fe1753cd4 100644 --- a/includes/job/jobs/AssembleUploadChunksJob.php +++ b/includes/job/jobs/AssembleUploadChunksJob.php @@ -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' ) ) ); diff --git a/includes/job/jobs/EnotifNotifyJob.php b/includes/job/jobs/EnotifNotifyJob.php index 2be05b6324..bbe988d04b 100644 --- a/includes/job/jobs/EnotifNotifyJob.php +++ b/includes/job/jobs/EnotifNotifyJob.php @@ -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 { diff --git a/includes/job/jobs/HTMLCacheUpdateJob.php b/includes/job/jobs/HTMLCacheUpdateJob.php index 376b3884af..44c240bb30 100644 --- a/includes/job/jobs/HTMLCacheUpdateJob.php +++ b/includes/job/jobs/HTMLCacheUpdateJob.php @@ -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 ); } diff --git a/includes/job/jobs/PublishStashedFileJob.php b/includes/job/jobs/PublishStashedFileJob.php index d3feda2834..625e8aa088 100644 --- a/includes/job/jobs/PublishStashedFileJob.php +++ b/includes/job/jobs/PublishStashedFileJob.php @@ -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' ) ) ); diff --git a/includes/job/jobs/RefreshLinksJob.php b/includes/job/jobs/RefreshLinksJob.php index 261ae63e50..4a5ecfc3d6 100644 --- a/includes/job/jobs/RefreshLinksJob.php +++ b/includes/job/jobs/RefreshLinksJob.php @@ -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 ); }