From: umherirrender Date: Sat, 20 Apr 2013 20:28:52 +0000 (+0200) Subject: Fixed spacing in db/debug/diff/externalstore/objectcache folder X-Git-Tag: 1.31.0-rc.0~19929 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=892ee7a4af4714c09e4ec7a74408f53f8256ae35;p=lhc%2Fweb%2Fwiklou.git Fixed spacing in db/debug/diff/externalstore/objectcache folder Added spaces before if, foreach Added some braces for one line statements Change-Id: I32a43c547630ce31b6b25cc1bc9eedc50e67b2d7 --- diff --git a/includes/db/CloneDatabase.php b/includes/db/CloneDatabase.php index 4e443741bc..2603b9fae1 100644 --- a/includes/db/CloneDatabase.php +++ b/includes/db/CloneDatabase.php @@ -87,7 +87,7 @@ class CloneDatabase { * Clone the table structure */ public function cloneTableStructure() { - foreach( $this->tablesToClone as $tbl ) { + foreach ( $this->tablesToClone as $tbl ) { # Clean up from previous aborted run. So that table escaping # works correctly across DB engines, we need to change the pre- # fix back and forth so tableName() works right. @@ -98,7 +98,7 @@ class CloneDatabase { self::changePrefix( $this->newTablePrefix ); $newTableName = $this->db->tableName( $tbl, 'raw' ); - if( $this->dropCurrentTables && !in_array( $this->db->getType(), array( 'postgres', 'oracle' ) ) ) { + if ( $this->dropCurrentTables && !in_array( $this->db->getType(), array( 'postgres', 'oracle' ) ) ) { $this->db->dropTable( $tbl, __METHOD__ ); wfDebug( __METHOD__ . " dropping {$newTableName}\n", true ); //Dropping the oldTable because the prefix was changed @@ -115,9 +115,9 @@ class CloneDatabase { * @param bool $dropTables Optionally drop the tables we created */ public function destroy( $dropTables = false ) { - if( $dropTables ) { + if ( $dropTables ) { self::changePrefix( $this->newTablePrefix ); - foreach( $this->tablesToClone as $tbl ) { + foreach ( $this->tablesToClone as $tbl ) { $this->db->dropTable( $tbl ); } } diff --git a/includes/db/Database.php b/includes/db/Database.php index 87d5f815a3..63c9cfe6b3 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -732,7 +732,7 @@ abstract class DatabaseBase implements DatabaseType { $dbType = strtolower( $dbType ); $class = 'Database' . ucfirst( $dbType ); - if( in_array( $dbType, $canonicalDBTypes ) || ( class_exists( $class ) && is_subclass_of( $class, 'DatabaseBase' ) ) ) { + if ( in_array( $dbType, $canonicalDBTypes ) || ( class_exists( $class ) && is_subclass_of( $class, 'DatabaseBase' ) ) ) { return new $class( isset( $p['host'] ) ? $p['host'] : false, isset( $p['user'] ) ? $p['user'] : false, @@ -1636,7 +1636,7 @@ abstract class DatabaseBase implements DatabaseType { * @return bool|null */ public function indexExists( $table, $index, $fname = 'DatabaseBase::indexExists' ) { - if( !$this->tableExists( $table ) ) { + if ( !$this->tableExists( $table ) ) { return null; } @@ -2285,9 +2285,9 @@ abstract class DatabaseBase implements DatabaseType { protected function indexName( $index ) { // Backwards-compatibility hack $renamed = array( - 'ar_usertext_timestamp' => 'usertext_timestamp', - 'un_user_id' => 'user_id', - 'un_user_ip' => 'user_ip', + 'ar_usertext_timestamp' => 'usertext_timestamp', + 'un_user_id' => 'user_id', + 'un_user_ip' => 'user_ip', ); if ( isset( $renamed[$index] ) ) { @@ -2468,7 +2468,7 @@ abstract class DatabaseBase implements DatabaseType { $rows = array( $rows ); } - foreach( $rows as $row ) { + foreach ( $rows as $row ) { # Delete rows which collide if ( $uniqueIndexes ) { $sql = "DELETE FROM $quotedTable WHERE "; @@ -3122,13 +3122,13 @@ abstract class DatabaseBase implements DatabaseType { if ( $flush != 'flush' ) { if ( !$this->mTrxLevel ) { wfWarn( "$fname: No transaction to commit, something got out of sync!" ); - } elseif( $this->mTrxAutomatic ) { + } elseif ( $this->mTrxAutomatic ) { wfWarn( "$fname: Explicit commit of implicit transaction. Something may be out of sync!" ); } } else { if ( !$this->mTrxLevel ) { return; // nothing to do - } elseif( !$this->mTrxAutomatic ) { + } elseif ( !$this->mTrxAutomatic ) { wfWarn( "$fname: Flushing an explicit transaction, getting out of sync!" ); } } @@ -3674,11 +3674,11 @@ abstract class DatabaseBase implements DatabaseType { * @since 1.18 */ public function dropTable( $tableName, $fName = 'DatabaseBase::dropTable' ) { - if( !$this->tableExists( $tableName, $fName ) ) { + if ( !$this->tableExists( $tableName, $fName ) ) { return false; } $sql = "DROP TABLE " . $this->tableName( $tableName ); - if( $this->cascadingDeletes() ) { + if ( $this->cascadingDeletes() ) { $sql .= " CASCADE"; } return $this->query( $sql, $fName ); diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index 82b0e5a4d2..427fd3dbcf 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -96,7 +96,7 @@ class DatabaseMssql extends DatabaseBase { $connectionInfo = array(); - if( $dbName ) { + if ( $dbName ) { $connectionInfo['Database'] = $dbName; } @@ -109,7 +109,7 @@ class DatabaseMssql extends DatabaseBase { $ntAuthPassTest = strtolower( $password ); // Decide which auth scenerio to use - if( $ntAuthPassTest == 'ntauth' && $ntAuthUserTest == 'ntauth' ) { + if ( $ntAuthPassTest == 'ntauth' && $ntAuthUserTest == 'ntauth' ) { // Don't add credentials to $connectionInfo } else { $connectionInfo['UID'] = $user; @@ -344,7 +344,9 @@ class DatabaseMssql extends DatabaseBase { $rows = -1; if ( $res ) { $row = $this->fetchRow( $res ); - if ( isset( $row['EstimateRows'] ) ) $rows = $row['EstimateRows']; + if ( isset( $row['EstimateRows'] ) ) { + $rows = $row['EstimateRows']; + } } return $rows; } @@ -421,7 +423,7 @@ class DatabaseMssql extends DatabaseBase { $identity = null; $tableRaw = preg_replace( '#\[([^\]]*)\]#', '$1', $table ); // strip matching square brackets from table name $res = $this->doQuery( "SELECT NAME AS idColumn FROM SYS.IDENTITY_COLUMNS WHERE OBJECT_NAME(OBJECT_ID)='{$tableRaw}'" ); - if( $res && $res->numrows() ) { + if ( $res && $res->numrows() ) { // There is an identity for this table. $identity = array_pop( $res->fetch( SQLSRV_FETCH_ASSOC ) ); } @@ -434,11 +436,11 @@ class DatabaseMssql extends DatabaseBase { $identityClause = ''; // if we have an identity column - if( $identity ) { + if ( $identity ) { // iterate through foreach ( $a as $k => $v ) { if ( $k == $identity ) { - if( !is_null( $v ) ) { + if ( !is_null( $v ) ) { // there is a value being passed to us, we need to turn on and off inserted identity $sqlPre = "SET IDENTITY_INSERT $table ON;"; $sqlPost = ";SET IDENTITY_INSERT $table OFF;"; @@ -1009,7 +1011,7 @@ class MssqlResult { $rows = sqlsrv_fetch_array( $queryresult, SQLSRV_FETCH_ASSOC ); - foreach( $rows as $row ) { + foreach ( $rows as $row ) { if ( $row !== null ) { foreach ( $row as $k => $v ) { if ( is_object( $v ) && method_exists( $v, 'format' ) ) {// DateTime Object diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index d6f6809ca4..000993715b 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -42,7 +42,7 @@ class DatabaseMysql extends DatabaseBase { * @return resource */ protected function doQuery( $sql ) { - if( $this->bufferResults() ) { + if ( $this->bufferResults() ) { $ret = mysql_query( $sql, $this->mConn ); } else { $ret = mysql_unbuffered_query( $sql, $this->mConn ); @@ -153,7 +153,7 @@ class DatabaseMysql extends DatabaseBase { // Tell the server we're communicating with it in UTF-8. // This may engage various charset conversions. - if( $wgDBmysql5 ) { + if ( $wgDBmysql5 ) { $this->query( 'SET NAMES utf8', __METHOD__ ); } else { $this->query( 'SET NAMES binary', __METHOD__ ); @@ -210,7 +210,7 @@ class DatabaseMysql extends DatabaseBase { // Only check for CR_SERVER_LOST and CR_UNKNOWN_ERROR, as // these are the only errors mysql_fetch_object can cause. // See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html. - if( $errno == 2000 || $errno == 2013 ) { + if ( $errno == 2000 || $errno == 2013 ) { throw new DBUnexpectedError( $this, 'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() ) ); } return $row; @@ -234,7 +234,7 @@ class DatabaseMysql extends DatabaseBase { // Only check for CR_SERVER_LOST and CR_UNKNOWN_ERROR, as // these are the only errors mysql_fetch_object can cause. // See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html. - if( $errno == 2000 || $errno == 2013 ) { + if ( $errno == 2000 || $errno == 2013 ) { throw new DBUnexpectedError( $this, 'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() ) ); } return $row; @@ -328,7 +328,7 @@ class DatabaseMysql extends DatabaseBase { } else { $error = mysql_error(); } - if( $error ) { + if ( $error ) { $error .= ' (' . $this->mServer . ')'; } return $error; @@ -393,9 +393,9 @@ class DatabaseMysql extends DatabaseBase { return false; } $n = mysql_num_fields( $res->result ); - for( $i = 0; $i < $n; $i++ ) { + for ( $i = 0; $i < $n; $i++ ) { $meta = mysql_fetch_field( $res->result, $i ); - if( $field == $meta->name ) { + if ( $field == $meta->name ) { return new MySQLField( $meta ); } } @@ -452,7 +452,7 @@ class DatabaseMysql extends DatabaseBase { function strencode( $s ) { $sQuoted = mysql_real_escape_string( $s, $this->mConn ); - if( $sQuoted === false ) { + if ( $sQuoted === false ) { $this->ping(); $sQuoted = mysql_real_escape_string( $s, $this->mConn ); } @@ -537,11 +537,11 @@ class DatabaseMysql extends DatabaseBase { function getLagFromProcesslist() { wfDeprecated( __METHOD__, '1.19' ); $res = $this->query( 'SHOW PROCESSLIST', __METHOD__ ); - if( !$res ) { + if ( !$res ) { return false; } # Find slave SQL thread - foreach( $res as $row ) { + foreach ( $res as $row ) { /* This should work for most situations - when default db * for thread is not specified, it had no events executed, * and therefore it doesn't know yet how lagged it is. @@ -721,7 +721,7 @@ class DatabaseMysql extends DatabaseBase { $result = $this->query( "SELECT GET_LOCK($lockName, $timeout) AS lockstatus", $method ); $row = $this->fetchObject( $result ); - if( $row->lockstatus == 1 ) { + if ( $row->lockstatus == 1 ) { return true; } else { wfDebug( __METHOD__ . " failed to acquire lock\n" ); @@ -752,13 +752,13 @@ class DatabaseMysql extends DatabaseBase { public function lockTables( $read, $write, $method, $lowPriority = true ) { $items = array(); - foreach( $write as $table ) { + foreach ( $write as $table ) { $tbl = $this->tableName( $table ) . ( $lowPriority ? ' LOW_PRIORITY' : '' ) . ' WRITE'; $items[] = $tbl; } - foreach( $read as $table ) { + foreach ( $read as $table ) { $items[] = $this->tableName( $table ) . ' READ'; } $sql = "LOCK TABLES " . implode( ',', $items ); @@ -905,11 +905,11 @@ class DatabaseMysql extends DatabaseBase { $endArray = array(); - foreach( $result as $table ) { + foreach ( $result as $table ) { $vars = get_object_vars( $table ); $table = array_pop( $vars ); - if( !$prefix || strpos( $table, $prefix ) === 0 ) { + if ( !$prefix || strpos( $table, $prefix ) === 0 ) { $endArray[] = $table; } } @@ -923,7 +923,7 @@ class DatabaseMysql extends DatabaseBase { * @return bool|ResultWrapper */ public function dropTable( $tableName, $fName = 'DatabaseMysql::dropTable' ) { - if( !$this->tableExists( $tableName, $fName ) ) { + if ( !$this->tableExists( $tableName, $fName ) ) { return false; } return $this->query( "DROP TABLE IF EXISTS " . $this->tableName( $tableName ), $fName ); diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index a57b24b7b4..a3f6805252 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -324,7 +324,7 @@ class DatabaseOracle extends DatabaseBase { // handle some oracle specifics // remove AS column/table/subquery namings - if( !$this->getFlag( DBO_DDLMODE ) ) { + if ( !$this->getFlag( DBO_DDLMODE ) ) { $sql = preg_replace( '/ as /i', ' ', $sql ); } @@ -756,7 +756,7 @@ class DatabaseOracle extends DatabaseBase { function unionQueries( $sqls, $all ) { $glue = ' UNION ALL '; - return 'SELECT * ' . ( $all ? '':'/* UNION_UNIQUE */ ' ) . 'FROM (' . implode( $glue, $sqls ) . ')'; + return 'SELECT * ' . ( $all ? '' : '/* UNION_UNIQUE */ ' ) . 'FROM (' . implode( $glue, $sqls ) . ')'; } function wasDeadlock() { @@ -792,8 +792,9 @@ class DatabaseOracle extends DatabaseBase { $endArray[] = strtoupper( $prefix . 'IMAGE' ); $fixedOrderTabs = $endArray; while ( ( $row = $result->fetchRow() ) !== false ) { - if ( !in_array( $row['table_name'], $fixedOrderTabs ) ) + if ( !in_array( $row['table_name'], $fixedOrderTabs ) ) { $endArray[] = $row['table_name']; + } } return $endArray; @@ -801,7 +802,7 @@ class DatabaseOracle extends DatabaseBase { public function dropTable( $tableName, $fName = 'DatabaseOracle::dropTable' ) { $tableName = $this->tableName( $tableName ); - if( !$this->tableExists( $tableName ) ) { + if ( !$this->tableExists( $tableName ) ) { return false; } @@ -906,7 +907,7 @@ class DatabaseOracle extends DatabaseBase { if ( is_array( $table ) ) { $table = array_map( array( &$this, 'tableNameInternal' ), $table ); $tableWhere = 'IN ('; - foreach( $table as &$singleTable ) { + foreach ( $table as &$singleTable ) { $singleTable = $this->removeIdentifierQuotes( $singleTable ); if ( isset( $this->mFieldInfoCache["$singleTable.$field"] ) ) { return $this->mFieldInfoCache["$singleTable.$field"]; @@ -931,7 +932,7 @@ class DatabaseOracle extends DatabaseBase { $res = new ORAResult( $this, $fieldInfoStmt ); if ( $res->numRows() == 0 ) { if ( is_array( $table ) ) { - foreach( $table as &$singleTable ) { + foreach ( $table as &$singleTable ) { $this->mFieldInfoCache["$singleTable.$field"] = false; } } else { diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index bb35dc3fc4..704b70edf8 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -117,7 +117,7 @@ SQL; * @since 1.19 */ function defaultValue() { - if( $this->has_default ) { + if ( $this->has_default ) { return $this->default; } else { return false; @@ -139,15 +139,15 @@ class PostgresTransactionState { array( "desc" => "%s: Connection state changed from %s -> %s\n", "states" => array( - PGSQL_CONNECTION_OK => "OK", - PGSQL_CONNECTION_BAD => "BAD" + PGSQL_CONNECTION_OK => "OK", + PGSQL_CONNECTION_BAD => "BAD" ) ), array( "desc" => "%s: Transaction state changed from %s -> %s\n", "states" => array( - PGSQL_TRANSACTION_IDLE => "IDLE", - PGSQL_TRANSACTION_ACTIVE => "ACTIVE", + PGSQL_TRANSACTION_IDLE => "IDLE", + PGSQL_TRANSACTION_ACTIVE => "ACTIVE", PGSQL_TRANSACTION_INTRANS => "TRANS", PGSQL_TRANSACTION_INERROR => "ERROR", PGSQL_TRANSACTION_UNKNOWN => "UNKNOWN" @@ -189,7 +189,7 @@ class PostgresTransactionState { } protected function describe_changed( $status, $desc_table ) { - if( isset( $desc_table[$status] ) ) { + if ( isset( $desc_table[$status] ) ) { return $desc_table[$status]; } else { return "STATUS " . $status; @@ -438,7 +438,7 @@ class DatabasePostgres extends DatabaseBase { $sql = mb_convert_encoding( $sql, 'UTF-8' ); } $this->mTransactionState->check(); - if( pg_send_query( $this->mConn, $sql ) === false ) { + if ( pg_send_query( $this->mConn, $sql ) === false ) { throw new DBUnexpectedError( $this, "Unable to post new query to PostgreSQL\n" ); } $this->mLastResult = pg_get_result( $this->mConn ); @@ -464,7 +464,7 @@ class DatabasePostgres extends DatabaseBase { PGSQL_DIAG_SOURCE_LINE, PGSQL_DIAG_SOURCE_FUNCTION ); foreach ( $diags as $d ) { - wfDebug( sprintf("PgSQL ERROR(%d): %s\n", $d, pg_result_error_field( $this->mLastResult, $d ) ) ); + wfDebug( sprintf( "PgSQL ERROR(%d): %s\n", $d, pg_result_error_field( $this->mLastResult, $d ) ) ); } } @@ -509,7 +509,7 @@ class DatabasePostgres extends DatabaseBase { # @todo hashar: not sure if the following test really trigger if the object # fetching failed. - if( pg_last_error( $this->mConn ) ) { + if ( pg_last_error( $this->mConn ) ) { throw new DBUnexpectedError( $this, 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) ) ); } return $row; @@ -522,7 +522,7 @@ class DatabasePostgres extends DatabaseBase { wfSuppressWarnings(); $row = pg_fetch_array( $res ); wfRestoreWarnings(); - if( pg_last_error( $this->mConn ) ) { + if ( pg_last_error( $this->mConn ) ) { throw new DBUnexpectedError( $this, 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) ) ); } return $row; @@ -535,7 +535,7 @@ class DatabasePostgres extends DatabaseBase { wfSuppressWarnings(); $n = pg_num_rows( $res ); wfRestoreWarnings(); - if( pg_last_error( $this->mConn ) ) { + if ( pg_last_error( $this->mConn ) ) { throw new DBUnexpectedError( $this, 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) ) ); } return $n; @@ -596,7 +596,7 @@ class DatabasePostgres extends DatabaseBase { // Forced result for simulated queries return $this->mAffectedRows; } - if( empty( $this->mLastResult ) ) { + if ( empty( $this->mLastResult ) ) { return 0; } return pg_affected_rows( $this->mLastResult ); @@ -617,7 +617,7 @@ class DatabasePostgres extends DatabaseBase { if ( $res ) { $row = $this->fetchRow( $res ); $count = array(); - if( preg_match( '/rows=(\d+)/', $row[0], $count ) ) { + if ( preg_match( '/rows=(\d+)/', $row[0], $count ) ) { $rows = $count[1]; } } @@ -650,8 +650,9 @@ class DatabasePostgres extends DatabaseBase { * @return Array */ function indexAttributes( $index, $schema = false ) { - if ( $schema === false ) + if ( $schema === false ) { $schema = $this->getCoreSchema(); + } /* * A subquery would be not needed if we didn't care about the order * of attributes, but we do @@ -854,7 +855,7 @@ __INDEXATTR__; { $destTable = $this->tableName( $destTable ); - if( !is_array( $insertOptions ) ) { + if ( !is_array( $insertOptions ) ) { $insertOptions = array( $insertOptions ); } @@ -870,11 +871,11 @@ __INDEXATTR__; $savepoint->savepoint(); } - if( !is_array( $selectOptions ) ) { + if ( !is_array( $selectOptions ) ) { $selectOptions = array( $selectOptions ); } list( $startOpts, $useIndex, $tailOpts ) = $this->makeSelectOptions( $selectOptions ); - if( is_array( $srcTable ) ) { + if ( is_array( $srcTable ) ) { $srcTable = implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) ); } else { $srcTable = $this->tableName( $srcTable ); @@ -891,9 +892,9 @@ __INDEXATTR__; $sql .= " $tailOpts"; $res = (bool)$this->query( $sql, $fname, $savepoint ); - if( $savepoint ) { + if ( $savepoint ) { $bar = pg_last_error(); - if( $bar != false ) { + if ( $bar != false ) { $savepoint->rollback(); } else { $savepoint->release(); @@ -989,10 +990,10 @@ __INDEXATTR__; $result = $this->query( "SELECT tablename FROM pg_tables WHERE schemaname = $eschema", $fname ); $endArray = array(); - foreach( $result as $table ) { + foreach ( $result as $table ) { $vars = get_object_vars( $table ); $table = array_pop( $vars ); - if( !$prefix || strpos( $table, $prefix ) === 0 ) { + if ( !$prefix || strpos( $table, $prefix ) === 0 ) { $endArray[] = $table; } } @@ -1023,11 +1024,11 @@ __INDEXATTR__; * @return string */ function pg_array_parse( $text, &$output, $limit = false, $offset = 1 ) { - if( false === $limit ) { + if ( false === $limit ) { $limit = strlen( $text ) - 1; $output = array(); } - if( '{}' == $text ) { + if ( '{}' == $text ) { return $output; } do { diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index e2434a0329..f702047885 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -78,7 +78,7 @@ class LoadBalancer { } } - foreach( $params['servers'] as $i => $server ) { + foreach ( $params['servers'] as $i => $server ) { $this->mLoads[$i] = $server['load']; if ( isset( $server['groupLoads'] ) ) { foreach ( $server['groupLoads'] as $group => $ratio ) { @@ -665,7 +665,7 @@ class LoadBalancer { * @return bool */ function isOpen( $index ) { - if( !is_integer( $index ) ) { + if ( !is_integer( $index ) ) { return false; } return (bool)$this->getAnyOpenConnection( $index ); @@ -682,7 +682,7 @@ class LoadBalancer { * @return DatabaseBase */ function reallyOpenConnection( $server, $dbNameOverride = false ) { - if( !is_array( $server ) ) { + if ( !is_array( $server ) ) { throw new MWException( 'You must update your load-balancing configuration. ' . 'See DefaultSettings.php entry for $wgDBservers.' ); } @@ -833,7 +833,7 @@ class LoadBalancer { */ function closeAll() { foreach ( $this->mConns as $conns2 ) { - foreach ( $conns2 as $conns3 ) { + foreach ( $conns2 as $conns3 ) { foreach ( $conns3 as $conn ) { $conn->close(); } diff --git a/includes/db/LoadMonitor.php b/includes/db/LoadMonitor.php index ad7b3b2fd6..4b9eccea4b 100644 --- a/includes/db/LoadMonitor.php +++ b/includes/db/LoadMonitor.php @@ -135,8 +135,9 @@ class LoadMonitor_MySQL implements LoadMonitor { $requestRate = 10; global $wgMemc; - if ( empty( $wgMemc ) ) + if ( empty( $wgMemc ) ) { $wgMemc = wfGetMainCache(); + } $masterName = $this->parent->getServerName( 0 ); $memcKey = wfMemcKey( 'lag_times', $masterName ); diff --git a/includes/debug/Debug.php b/includes/debug/Debug.php index 582b3ac716..d75a126b7f 100644 --- a/includes/debug/Debug.php +++ b/includes/debug/Debug.php @@ -484,10 +484,10 @@ class MWDebug { // output errors as debug info, when display_errors is on // this is necessary for all non html output of the api, because that clears all errors first $obContents = ob_get_contents(); - if( $obContents ) { + if ( $obContents ) { $obContentArray = explode( '
', $obContents ); - foreach( $obContentArray as $obContent ) { - if( trim( $obContent ) ) { + foreach ( $obContentArray as $obContent ) { + if ( trim( $obContent ) ) { self::debugMsg( Sanitizer::stripAllTags( $obContent ) ); } } @@ -498,7 +498,7 @@ class MWDebug { $result->setIndexedTagName( $debugInfo, 'debuginfo' ); $result->setIndexedTagName( $debugInfo['log'], 'line' ); - foreach( $debugInfo['debugLog'] as $index => $debugLogText ) { + foreach ( $debugInfo['debugLog'] as $index => $debugLogText ) { $vals = array(); ApiResult::setContent( $vals, $debugLogText ); $debugInfo['debugLog'][$index] = $vals; //replace diff --git a/includes/diff/DairikiDiff.php b/includes/diff/DairikiDiff.php index f9cb6560af..e78045a88c 100644 --- a/includes/diff/DairikiDiff.php +++ b/includes/diff/DairikiDiff.php @@ -271,7 +271,8 @@ class _DiffEngine { $this->xchanged[$skip] = $this->ychanged[$skip] = false; } // Skip trailing common lines. - $xi = $n_from; $yi = $n_to; + $xi = $n_from; + $yi = $n_to; for ( $endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++ ) { if ( $from_lines[$xi] !== $to_lines[$yi] ) { break; @@ -394,7 +395,7 @@ class _DiffEngine { break; } } - while ( list ( , $y ) = each( $matches ) ) { + while ( list( , $y ) = each( $matches ) ) { if ( $y > $this->seq[$k -1] ) { assert( '$y < $this->seq[$k]' ); // Optimization: this is a common case: @@ -471,8 +472,7 @@ class _DiffEngine { */ function _compareseq( $xoff, $xlim, $yoff, $ylim ) { // Slide down the bottom initial diagonal. - while ( $xoff < $xlim && $yoff < $ylim - && $this->xv[$xoff] == $this->yv[$yoff] ) { + while ( $xoff < $xlim && $yoff < $ylim && $this->xv[$xoff] == $this->yv[$yoff] ) { ++$xoff; ++$yoff; } @@ -491,7 +491,7 @@ class _DiffEngine { // $nchunks = sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); // $nchunks = max(2,min(8,(int)$nchunks)); $nchunks = min( 7, $xlim - $xoff, $ylim - $yoff ) + 1; - list ( $lcs, $seps ) = $this->_diag( $xoff, $xlim, $yoff, $ylim, $nchunks ); + list( $lcs, $seps ) = $this->_diag( $xoff, $xlim, $yoff, $ylim, $nchunks ); } if ( $lcs == 0 ) { @@ -554,9 +554,11 @@ class _DiffEngine { while ( $i < $len && ! $changed[$i] ) { assert( '$j < $other_len && ! $other_changed[$j]' ); - $i++; $j++; - while ( $j < $other_len && $other_changed[$j] ) + $i++; $j++; + while ( $j < $other_len && $other_changed[$j] ) { + $j++; + } } if ( $i == $len ) { diff --git a/includes/externalstore/ExternalStoreDB.php b/includes/externalstore/ExternalStoreDB.php index 46a863f88b..99192369c0 100644 --- a/includes/externalstore/ExternalStoreDB.php +++ b/includes/externalstore/ExternalStoreDB.php @@ -152,7 +152,7 @@ class ExternalStoreDB extends ExternalStoreMedium { static $externalBlobCache = array(); $cacheID = ( $itemID === false ) ? "$cluster/$id" : "$cluster/$id/"; - if( isset( $externalBlobCache[$cacheID] ) ) { + if ( isset( $externalBlobCache[$cacheID] ) ) { wfDebugLog( 'ExternalStoreDB-cache', "ExternalStoreDB::fetchBlob cache hit on $cacheID\n" ); return $externalBlobCache[$cacheID]; } @@ -166,11 +166,11 @@ class ExternalStoreDB extends ExternalStoreMedium { // Try the master $dbw =& $this->getMaster( $cluster ); $ret = $dbw->selectField( $this->getTable( $dbw ), 'blob_text', array( 'blob_id' => $id ), __METHOD__ ); - if( $ret === false) { + if ( $ret === false) { wfDebugLog( 'ExternalStoreDB', "ExternalStoreDB::fetchBlob master failed to find $cacheID\n" ); } } - if( $itemID !== false && $ret !== false ) { + if ( $itemID !== false && $ret !== false ) { // Unserialise object; caller extracts item $ret = unserialize( $ret ); } diff --git a/includes/objectcache/BagOStuff.php b/includes/objectcache/BagOStuff.php index fbde251ff6..58ddd6a001 100644 --- a/includes/objectcache/BagOStuff.php +++ b/includes/objectcache/BagOStuff.php @@ -187,7 +187,7 @@ abstract class BagOStuff { } usleep( $sleep ); // back off $locked = $this->add( "{$key}:lock", $timeout ); - } while( !$locked ); + } while ( !$locked ); return $locked; } diff --git a/includes/objectcache/MemcachedBagOStuff.php b/includes/objectcache/MemcachedBagOStuff.php index 3f1fa3a052..f1644edbf7 100644 --- a/includes/objectcache/MemcachedBagOStuff.php +++ b/includes/objectcache/MemcachedBagOStuff.php @@ -43,7 +43,7 @@ class MemcachedBagOStuff extends BagOStuff { if ( !isset( $params['persistent'] ) ) { $params['persistent'] = $GLOBALS['wgMemCachedPersistent']; } - if ( !isset( $params['compress_threshold'] ) ) { + if ( !isset( $params['compress_threshold'] ) ) { $params['compress_threshold'] = 1500; } if ( !isset( $params['timeout'] ) ) { diff --git a/includes/objectcache/MemcachedClient.php b/includes/objectcache/MemcachedClient.php index bc2acb37ae..f4c034afba 100644 --- a/includes/objectcache/MemcachedClient.php +++ b/includes/objectcache/MemcachedClient.php @@ -329,7 +329,7 @@ class MWMemcached { $this->stats['delete'] = 1; } $cmd = "delete $key $time\r\n"; - if( !$this->_fwrite( $sock, $cmd ) ) { + if ( !$this->_fwrite( $sock, $cmd ) ) { return false; } $res = $this->_fgets( $sock ); @@ -733,7 +733,7 @@ class MWMemcached { $sock = false; $timeout = $this->_connect_timeout; $errno = $errstr = null; - for( $i = 0; !$sock && $i < $this->_connect_attempts; $i++ ) { + for ( $i = 0; !$sock && $i < $this->_connect_attempts; $i++ ) { wfSuppressWarnings(); if ( $this->_persistent == 1 ) { $sock = pfsockopen( $ip, $port, $errno, $errstr, $timeout ); @@ -810,7 +810,7 @@ class MWMemcached { $bu = array(); foreach ( $this->_servers as $v ) { if ( is_array( $v ) ) { - for( $i = 0; $i < $v[1]; $i++ ) { + for ( $i = 0; $i < $v[1]; $i++ ) { $bu[] = $v[0]; } } else { @@ -822,7 +822,7 @@ class MWMemcached { } $realkey = is_array( $key ) ? $key[1] : $key; - for( $tries = 0; $tries < 20; $tries++ ) { + for ( $tries = 0; $tries < 20; $tries++ ) { $host = $this->_buckets[$hv % $this->_bucketcount]; $sock = $this->sock_to_host( $host ); if ( is_resource( $sock ) ) { @@ -912,7 +912,7 @@ class MWMemcached { while ( 1 ) { $decl = $this->_fgets( $sock ); - if( $decl === false ) { + if ( $decl === false ) { /* * If nothing can be read, something is wrong because we know exactly when * to stop reading (right after "END") and we return right after that. diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php index eafa836a4a..f7247f92f5 100644 --- a/includes/objectcache/ObjectCache.php +++ b/includes/objectcache/ObjectCache.php @@ -125,9 +125,9 @@ class ObjectCache { static function newAccelerator( $params ) { if ( function_exists( 'apc_fetch' ) ) { $id = 'apc'; - } elseif( function_exists( 'xcache_get' ) && wfIniGetBool( 'xcache.var_size' ) ) { + } elseif ( function_exists( 'xcache_get' ) && wfIniGetBool( 'xcache.var_size' ) ) { $id = 'xcache'; - } elseif( function_exists( 'wincache_ucache_get' ) ) { + } elseif ( function_exists( 'wincache_ucache_get' ) ) { $id = 'wincache'; } else { throw new MWException( "CACHE_ACCEL requested but no suitable object " . diff --git a/includes/objectcache/ObjectCacheSessionHandler.php b/includes/objectcache/ObjectCacheSessionHandler.php index bc76294a55..7cf960e7d0 100644 --- a/includes/objectcache/ObjectCacheSessionHandler.php +++ b/includes/objectcache/ObjectCacheSessionHandler.php @@ -94,7 +94,7 @@ class ObjectCacheSessionHandler { */ static function read( $id ) { $data = self::getCache()->get( self::getKey( $id ) ); - if( $data === false ) { + if ( $data === false ) { return ''; } return $data;