From 86463f3df6c425767ab7b3ed3aa7ab448708367d Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Sun, 10 Sep 2017 21:11:37 +0200 Subject: [PATCH] build: Updating mediawiki/mediawiki-codesniffer to 0.12.0 Change-Id: Iefaae5043fa77d5d556c31079549dab8f61bd3ef --- composer.json | 2 +- includes/OutputPage.php | 2 +- .../libs/filebackend/FileBackendStore.php | 2 +- includes/libs/objectcache/BagOStuff.php | 2 +- .../libs/objectcache/MemcachedBagOStuff.php | 2 +- includes/libs/objectcache/WANObjectCache.php | 2 +- includes/libs/rdbms/TransactionProfiler.php | 2 +- includes/libs/rdbms/database/Database.php | 4 ++-- .../libs/rdbms/loadmonitor/LoadMonitor.php | 2 +- includes/parser/ParserOutput.php | 2 +- phpcs.xml | 3 +++ .../GlobalFunctions/wfTimestampTest.php | 2 +- .../libs/objectcache/WANObjectCacheTest.php | 10 ++++---- .../libs/rdbms/TransactionProfilerTest.php | 24 +++++++++---------- .../rdbms/database/DatabaseMysqlBaseTest.php | 4 ++-- 15 files changed, 34 insertions(+), 31 deletions(-) diff --git a/composer.json b/composer.json index dd7567c93c..70d2e8f310 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "jakub-onderka/php-parallel-lint": "0.9.2", "jetbrains/phpstorm-stubs": "dev-master#1b9906084d6635456fcf3f3a01f0d7d5b99a578a", "justinrainbow/json-schema": "~5.2", - "mediawiki/mediawiki-codesniffer": "0.11.0", + "mediawiki/mediawiki-codesniffer": "0.12.0", "monolog/monolog": "~1.22.1", "nikic/php-parser": "2.1.0", "nmred/kafka-php": "0.1.5", diff --git a/includes/OutputPage.php b/includes/OutputPage.php index dd21194bdb..b71ae89cfa 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2013,7 +2013,7 @@ class OutputPage extends ContextSource { } $age = time() - wfTimestamp( TS_UNIX, $mtime ); - $adaptiveTTL = max( .9 * $age, $minTTL ); + $adaptiveTTL = max( 0.9 * $age, $minTTL ); $adaptiveTTL = min( $adaptiveTTL, $maxTTL ); $this->lowerCdnMaxage( (int)$adaptiveTTL ); diff --git a/includes/libs/filebackend/FileBackendStore.php b/includes/libs/filebackend/FileBackendStore.php index 77473d139c..b8eec3f01d 100644 --- a/includes/libs/filebackend/FileBackendStore.php +++ b/includes/libs/filebackend/FileBackendStore.php @@ -1714,7 +1714,7 @@ abstract class FileBackendStore extends FileBackend { return; // invalid storage path } $mtime = ConvertibleTimestamp::convert( TS_UNIX, $val['mtime'] ); - $ttl = $this->memCache->adaptiveTTL( $mtime, 7 * 86400, 300, .1 ); + $ttl = $this->memCache->adaptiveTTL( $mtime, 7 * 86400, 300, 0.1 ); $key = $this->fileCacheKey( $path ); // Set the cache unless it is currently salted. $this->memCache->set( $key, $val, $ttl ); diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index f834ccf937..8a23db515b 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -476,7 +476,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { $lSince = microtime( true ); // lock timestamp return new ScopedCallback( function () use ( $key, $lSince, $expiry ) { - $latency = .050; // latency skew (err towards keeping lock present) + $latency = 0.050; // latency skew (err towards keeping lock present) $age = ( microtime( true ) - $lSince + $latency ); if ( ( $age + $latency ) >= $expiry ) { $this->logger->warning( "Lock for $key held too long ($age sec)." ); diff --git a/includes/libs/objectcache/MemcachedBagOStuff.php b/includes/libs/objectcache/MemcachedBagOStuff.php index 5128d824b2..0188991aa0 100644 --- a/includes/libs/objectcache/MemcachedBagOStuff.php +++ b/includes/libs/objectcache/MemcachedBagOStuff.php @@ -45,7 +45,7 @@ class MemcachedBagOStuff extends BagOStuff { protected function applyDefaultParams( $params ) { return $params + [ 'compress_threshold' => 1500, - 'connect_timeout' => .5, + 'connect_timeout' => 0.5, 'debug' => false ]; } diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index c1c9cc1a8a..1f757a41e9 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -1424,7 +1424,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return int Adaptive TTL * @since 1.28 */ - public function adaptiveTTL( $mtime, $maxTTL, $minTTL = 30, $factor = .2 ) { + public function adaptiveTTL( $mtime, $maxTTL, $minTTL = 30, $factor = 0.2 ) { if ( is_float( $mtime ) || ctype_digit( $mtime ) ) { $mtime = (int)$mtime; // handle fractional seconds and string integers } diff --git a/includes/libs/rdbms/TransactionProfiler.php b/includes/libs/rdbms/TransactionProfiler.php index af431a6787..57a12a4463 100644 --- a/includes/libs/rdbms/TransactionProfiler.php +++ b/includes/libs/rdbms/TransactionProfiler.php @@ -39,7 +39,7 @@ class TransactionProfiler implements LoggerAwareInterface { /** @var float Seconds */ protected $dbLockThreshold = 3.0; /** @var float Seconds */ - protected $eventThreshold = .25; + protected $eventThreshold = 0.25; /** @var bool */ protected $silenced = false; diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index 2c66d74860..c9040928b0 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -54,8 +54,8 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware const PING_TTL = 1.0; const PING_QUERY = 'SELECT 1 AS ping'; - const TINY_WRITE_SEC = .010; - const SLOW_WRITE_SEC = .500; + const TINY_WRITE_SEC = 0.010; + const SLOW_WRITE_SEC = 0.500; const SMALL_WRITE_ROWS = 100; /** @var string SQL query */ diff --git a/includes/libs/rdbms/loadmonitor/LoadMonitor.php b/includes/libs/rdbms/loadmonitor/LoadMonitor.php index fdc5ac8146..8292c0369b 100644 --- a/includes/libs/rdbms/loadmonitor/LoadMonitor.php +++ b/includes/libs/rdbms/loadmonitor/LoadMonitor.php @@ -157,7 +157,7 @@ class LoadMonitor implements ILoadMonitor { $newWeight = $movAveRatio * $coefficient + ( 1 - $movAveRatio ) * $lastWeight; // Scale from 10% to 100% of nominal weight - $weightScales[$i] = max( $newWeight, .10 ); + $weightScales[$i] = max( $newWeight, 0.10 ); if ( !$conn ) { $lagTimes[$i] = false; diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 2981748098..06319e5575 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -223,7 +223,7 @@ class ParserOutput extends CacheTime { // finalizeAdaptiveCacheExpiry() uses TTL = MAX( m * PARSE_TIME + b, MIN_AR_TTL) // Current values imply that m=3933.333333 and b=-333.333333 // See https://www.nngroup.com/articles/website-response-times/ - const PARSE_FAST_SEC = .100; // perceived "fast" page parse + const PARSE_FAST_SEC = 0.100; // perceived "fast" page parse const PARSE_SLOW_SEC = 1.0; // perceived "slow" page parse const FAST_AR_TTL = 60; // adaptive TTL for "fast" pages const SLOW_AR_TTL = 3600; // adaptive TTL for "slow" pages diff --git a/phpcs.xml b/phpcs.xml index 4c5266e419..bd9890b231 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -20,6 +20,9 @@ + + + diff --git a/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php b/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php index b6682f7274..a70f136a1c 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php @@ -21,7 +21,7 @@ class WfTimestampTest extends MediaWikiTestCase { [ -30281104, TS_MW, '19690115123456', 'Negative TS_UNIX to TS_MW' ], [ $t, TS_UNIX, 979562096, 'TS_UNIX to TS_UNIX' ], [ $t, TS_DB, '2001-01-15 12:34:56', 'TS_UNIX to TS_DB' ], - [ $t + .01, TS_MW, '20010115123456', 'TS_UNIX float to TS_MW' ], + [ $t + 0.01, TS_MW, '20010115123456', 'TS_UNIX float to TS_MW' ], [ $t, TS_ISO_8601_BASIC, '20010115T123456Z', 'TS_ISO_8601_BASIC to TS_DB' ], diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index 881ace272f..c762aa7d70 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -1184,11 +1184,11 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase { public static function provideAdaptiveTTL() { return [ - [ 3600, 900, 30, .2, 720 ], - [ 3600, 500, 30, .2, 500 ], - [ 3600, 86400, 800, .2, 800 ], - [ false, 86400, 800, .2, 800 ], - [ null, 86400, 800, .2, 800 ] + [ 3600, 900, 30, 0.2, 720 ], + [ 3600, 500, 30, 0.2, 500 ], + [ 3600, 86400, 800, 0.2, 800 ], + [ false, 86400, 800, 0.2, 800 ], + [ null, 86400, 800, 0.2, 800 ] ]; } diff --git a/tests/phpunit/includes/libs/rdbms/TransactionProfilerTest.php b/tests/phpunit/includes/libs/rdbms/TransactionProfilerTest.php index cb18fb3dc3..b6ea4265ba 100644 --- a/tests/phpunit/includes/libs/rdbms/TransactionProfilerTest.php +++ b/tests/phpunit/includes/libs/rdbms/TransactionProfilerTest.php @@ -112,10 +112,10 @@ class TransactionProfilerTest extends PHPUnit_Framework_TestCase { $tp->setLogger( $logger ); $tp->setExpectation( 'queries', 2, __METHOD__ ); - $tp->recordQueryCompletion( "SQL 1", microtime( true ) - .01, false, 0 ); - $tp->recordQueryCompletion( "SQL 2", microtime( true ) - .01, false, 0 ); - $tp->recordQueryCompletion( "SQL 3", microtime( true ) - .01, false, 0 ); // warn - $tp->recordQueryCompletion( "SQL 4", microtime( true ) - .01, false, 0 ); // warn + $tp->recordQueryCompletion( "SQL 1", microtime( true ) - 0.01, false, 0 ); + $tp->recordQueryCompletion( "SQL 2", microtime( true ) - 0.01, false, 0 ); + $tp->recordQueryCompletion( "SQL 3", microtime( true ) - 0.01, false, 0 ); // warn + $tp->recordQueryCompletion( "SQL 4", microtime( true ) - 0.01, false, 0 ); // warn } public function testWriteQueryCount() { @@ -126,16 +126,16 @@ class TransactionProfilerTest extends PHPUnit_Framework_TestCase { $tp->setLogger( $logger ); $tp->setExpectation( 'writes', 2, __METHOD__ ); - $tp->recordQueryCompletion( "SQL 1", microtime( true ) - .01, false, 0 ); - $tp->recordQueryCompletion( "SQL 2", microtime( true ) - .01, false, 0 ); - $tp->recordQueryCompletion( "SQL 3", microtime( true ) - .01, false, 0 ); - $tp->recordQueryCompletion( "SQL 4", microtime( true ) - .01, false, 0 ); + $tp->recordQueryCompletion( "SQL 1", microtime( true ) - 0.01, false, 0 ); + $tp->recordQueryCompletion( "SQL 2", microtime( true ) - 0.01, false, 0 ); + $tp->recordQueryCompletion( "SQL 3", microtime( true ) - 0.01, false, 0 ); + $tp->recordQueryCompletion( "SQL 4", microtime( true ) - 0.01, false, 0 ); $tp->transactionWritingIn( 'srv1', 'db1', '123' ); - $tp->recordQueryCompletion( "SQL 1w", microtime( true ) - .01, true, 2 ); - $tp->recordQueryCompletion( "SQL 2w", microtime( true ) - .01, true, 5 ); - $tp->recordQueryCompletion( "SQL 3w", microtime( true ) - .01, true, 3 ); - $tp->recordQueryCompletion( "SQL 4w", microtime( true ) - .01, true, 1 ); + $tp->recordQueryCompletion( "SQL 1w", microtime( true ) - 0.01, true, 2 ); + $tp->recordQueryCompletion( "SQL 2w", microtime( true ) - 0.01, true, 5 ); + $tp->recordQueryCompletion( "SQL 3w", microtime( true ) - 0.01, true, 3 ); + $tp->recordQueryCompletion( "SQL 4w", microtime( true ) - 0.01, true, 1 ); $tp->transactionWritingOut( 'srv1', 'db1', '123', 1, 1 ); } } diff --git a/tests/phpunit/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php b/tests/phpunit/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php index b564310429..456447f01c 100644 --- a/tests/phpunit/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php +++ b/tests/phpunit/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php @@ -352,8 +352,8 @@ class DatabaseMysqlBaseTest extends PHPUnit_Framework_TestCase { $db->setLBInfo( 'clusterMasterHost', 'db1052' ); $lagEst = $db->getLag(); - $this->assertGreaterThan( $lag - .010, $lagEst, "Correct heatbeat lag" ); - $this->assertLessThan( $lag + .010, $lagEst, "Correct heatbeat lag" ); + $this->assertGreaterThan( $lag - 0.010, $lagEst, "Correct heatbeat lag" ); + $this->assertLessThan( $lag + 0.010, $lagEst, "Correct heatbeat lag" ); } public static function provideLagAmounts() { -- 2.20.1