Merge "Add user autocomplete and autofocus to Special:ActiveUsers"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 6 Dec 2015 16:31:49 +0000 (16:31 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 6 Dec 2015 16:31:49 +0000 (16:31 +0000)
includes/ForkController.php
includes/clientpool/RedisConnectionPool.php
includes/libs/objectcache/WANObjectCache.php
includes/specials/SpecialContributions.php
includes/specials/SpecialTags.php
includes/utils/UIDGenerator.php
resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js
tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php

index c1765e2..4a021ee 100644 (file)
@@ -153,7 +153,9 @@ class ForkController {
                wfGetLBFactory()->destroyInstance();
                FileBackendGroup::destroySingleton();
                LockManagerGroup::destroySingletons();
+               JobQueueGroup::destroySingletons();
                ObjectCache::clear();
+               RedisConnectionPool::destroySingletons();
                $wgMemc = null;
        }
 
index 64db0d6..1b9f9b3 100644 (file)
@@ -166,6 +166,14 @@ class RedisConnectionPool implements LoggerAwareInterface {
                return self::$instances[$id];
        }
 
+       /**
+        * Destroy all singleton() instances
+        * @since 1.27
+        */
+       public static function destroySingletons() {
+               self::$instances = array();
+       }
+
        /**
         * Get a connection to a redis server. Based on code in RedisBagOStuff.php.
         *
index 4005abb..95bf743 100644 (file)
@@ -251,6 +251,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
 
                // Fetch all of the raw values
                $wrappedValues = $this->cache->getMulti( array_merge( $valueKeys, $checkKeysFlat ) );
+               // Time used to compare/init "check" keys (derived after getMulti() to be pessimistic)
                $now = microtime( true );
 
                // Collect timestamps from all "check" keys
@@ -282,7 +283,10 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
                                foreach ( $purgeValues as $purge ) {
                                        $safeTimestamp = $purge[self::FLD_TIME] + $purge[self::FLD_HOLDOFF];
                                        if ( $safeTimestamp >= $wrappedValues[$vKey][self::FLD_TIME] ) {
-                                               $curTTL = min( $curTTL, $purge[self::FLD_TIME] - $now );
+                                               // How long ago this value was expired by *this* check key
+                                               $ago = min( $purge[self::FLD_TIME] - $now, self::TINY_NEGATIVE );
+                                               // How long ago this value was expired by *any* known check key
+                                               $curTTL = min( $curTTL, $ago );
                                        }
                                }
                        }
index 71d2b23..b1908c2 100644 (file)
@@ -482,7 +482,7 @@ class SpecialContributions extends IncludableSpecialPage {
                        $filterSelection = Html::rawElement(
                                'td',
                                array(),
-                               array_shift( $tagFilter ) . implode( '&#160', $tagFilter )
+                               implode( '&#160', $tagFilter )
                        );
                } else {
                        $filterSelection = Html::rawElement( 'td', array( 'colspan' => 2 ), '' );
index 71f387b..97f2380 100644 (file)
@@ -451,6 +451,20 @@ class SpecialTags extends SpecialPage {
                }
        }
 
+       /**
+        * Return an array of subpages that this special page will accept.
+        *
+        * @return string[] subpages
+        */
+       public function getSubpagesForPrefixSearch() {
+               return array(
+                       'delete',
+                       'activate',
+                       'deactivate',
+                       'create',
+               );
+       }
+
        protected function getGroupName() {
                return 'changes';
        }
index 6171d58..e2de900 100644 (file)
@@ -429,6 +429,7 @@ class UIDGenerator {
         * @param string $lockFile Name of a local lock file
         * @param int $clockSeqSize The number of possible clock sequence values
         * @param int $counterSize The number of possible counter values
+        * @param int $offsetSize The number of possible offset values
         * @return array (result of UIDGenerator::millitime(), counter, clock sequence)
         * @throws RuntimeException
         */
index 5e79039..0117cea 100644 (file)
         * @return {string}
         */
        ForeignStructuredUpload.prototype.getDescriptions = function () {
-               var i, desc, hasEquals, templateCalls = [];
+               var i, desc, templateCalls = [];
 
                for ( i = 0; i < this.descriptions.length; i++ ) {
                        desc = this.descriptions[ i ];
-                       hasEquals = desc.text.indexOf( '=' ) !== -1;
-                       templateCalls.push( '{{' + desc.language + ( hasEquals ? '|1=' : '|' ) + desc.text + '}}' );
+                       templateCalls.push( '{{' + desc.language + '|1=' + desc.text + '}}' );
                }
 
                return templateCalls.join( '\n' );
index 1511557..efc37d2 100644 (file)
@@ -303,9 +303,9 @@ class WANObjectCacheTest extends MediaWikiTestCase {
                // Fake initial check key to be set in the past. Otherwise we'd have to sleep for
                // several seconds during the test to assert the behaviour.
                foreach ( array( $checkAll, $check1, $check2 ) as $checkKey ) {
-                       $this->internalCache->set( $cache::TIME_KEY_PREFIX . $checkKey,
-                               $cache::PURGE_VAL_PREFIX . microtime( true ) - $cache::HOLDOFF_TTL, $cache::CHECK_KEY_TTL );
+                       $cache->touchCheckKey( $checkKey, WANObjectCache::HOLDOFF_NONE );
                }
+               usleep( 100 );
 
                $cache->set( 'key1', $value1, 10 );
                $cache->set( 'key2', $value2, 10 );
@@ -322,14 +322,12 @@ class WANObjectCacheTest extends MediaWikiTestCase {
                        $result,
                        'Initial values'
                );
-               $this->assertEquals(
-                       array( 'key1' => 0, 'key2' => 0 ),
-                       $curTTLs,
-                       'Initial ttls'
-               );
+               $this->assertGreaterThanOrEqual( 9.5, $curTTLs['key1'], 'Initial ttls' );
+               $this->assertLessThanOrEqual( 10.5, $curTTLs['key1'], 'Initial ttls' );
+               $this->assertGreaterThanOrEqual( 9.5, $curTTLs['key2'], 'Initial ttls' );
+               $this->assertLessThanOrEqual( 10.5, $curTTLs['key2'], 'Initial ttls' );
 
                $cache->touchCheckKey( $check1 );
-               usleep( 100 );
 
                $curTTLs = array();
                $result = $cache->getMulti( array( 'key1', 'key2', 'key3' ), $curTTLs, array(
@@ -344,10 +342,9 @@ class WANObjectCacheTest extends MediaWikiTestCase {
                        'key1 expired by check1, but value still provided'
                );
                $this->assertLessThan( 0, $curTTLs['key1'], 'key1 TTL expired' );
-               $this->assertEquals( 0, $curTTLs['key2'], 'key2 still valid' );
+               $this->assertGreaterThan( 0, $curTTLs['key2'], 'key2 still valid' );
 
                $cache->touchCheckKey( $checkAll );
-               usleep( 100 );
 
                $curTTLs = array();
                $result = $cache->getMulti( array( 'key1', 'key2', 'key3' ), $curTTLs, array(
@@ -365,6 +362,39 @@ class WANObjectCacheTest extends MediaWikiTestCase {
                $this->assertLessThan( 0, $curTTLs['key2'], 'key2 expired by checkAll' );
        }
 
+       /**
+        * @covers WANObjectCache::get()
+        * @covers WANObjectCache::processCheckKeys()
+        */
+       public function testCheckKeyInitHoldoff() {
+               $cache = $this->cache;
+
+               for ( $i = 0; $i < 500; ++$i ) {
+                       $key = wfRandomString();
+                       $checkKey = wfRandomString();
+                       // miss, set, hit
+                       $cache->get( $key, $curTTL, array( $checkKey ) );
+                       $cache->set( $key, 'val', 10 );
+                       $curTTL = null;
+                       $v = $cache->get( $key, $curTTL, array( $checkKey ) );
+
+                       $this->assertEquals( 'val', $v );
+                       $this->assertLessThan( 0, $curTTL, "Step $i: CTL < 0 (miss/set/hit)" );
+               }
+
+               for ( $i = 0; $i < 500; ++$i ) {
+                       $key = wfRandomString();
+                       $checkKey = wfRandomString();
+                       // set, hit
+                       $cache->set( $key, 'val', 10 );
+                       $curTTL = null;
+                       $v = $cache->get( $key, $curTTL, array( $checkKey ) );
+
+                       $this->assertEquals( 'val', $v );
+                       $this->assertLessThan( 0, $curTTL, "Step $i: CTL < 0 (set/hit)" );
+               }
+       }
+
        /**
         * @covers WANObjectCache::delete()
         */