public function testCompositeShallow()
 {
     global $wgFlowCacheTime;
     $bag = new BufferedBagOStuff(new \HashBagOStuff());
     $cache = new BufferedCache($bag, $wgFlowCacheTime);
     $storage = $this->getMock('Flow\\Data\\ObjectStorage');
     $unique = new UniqueFeatureIndex($cache, $storage, 'unique', array('id', 'ot'));
     $secondary = new TopKIndex($cache, $storage, 'secondary', array('name'), array('shallow' => $unique, 'sort' => 'id'));
     // remember: unique index still stores an array of results to be consistent with other indexes
     // even though, due to uniqueness, there is only one value per set of keys
     $db = FeatureIndex::cachedDbId();
     $v = Container::get('cache.version');
     $bag->set("{$db}:unique:1:9:{$v}", array(array('id' => 1, 'ot' => 9, 'name' => 'foo')));
     $bag->set("{$db}:unique:1:8:{$v}", array(array('id' => 1, 'ot' => 8, 'name' => 'foo')));
     $bag->set("{$db}:unique:3:7:{$v}", array(array('id' => 3, 'ot' => 7, 'name' => 'baz')));
     $bag->set("{$db}:secondary:foo:{$v}", array(array('id' => 1, 'ot' => 9), array('id' => 1, 'ot' => 8)));
     $bag->set("{$db}:secondary:baz:{$v}", array(array('id' => 3, 'ot' => 7)));
     $expect = array(array('id' => 1, 'ot' => 9, 'name' => 'foo'), array('id' => 1, 'ot' => 8, 'name' => 'foo'));
     $this->assertEquals($expect, $secondary->find(array('name' => 'foo')));
     $expect = array(array('id' => 3, 'ot' => 7, 'name' => 'baz'));
     $this->assertEquals($expect, $secondary->find(array('name' => 'baz')));
 }
 public function onAfterRemove($object, array $old, array $metadata)
 {
     if (!$object instanceof Workflow) {
         parent::onAfterRemove($object, $old, $metadata);
     }
 }
 /**
  * @dataProvider includeOffsetProvider
  */
 public function testIncludeOffset($message, $expect, $queryOptions)
 {
     global $wgFlowCacheVersion;
     $bag = new \HashBagOStuff();
     $innerCache = new LocalBufferedBagOStuff($bag);
     $cache = new BufferedCache($innerCache);
     // preload our answer
     $bag->set(wfWikiId() . ":prefix:1:{$wgFlowCacheVersion}", array(array('foo' => 1, 'bar' => 9), array('foo' => 1, 'bar' => 8), array('foo' => 1, 'bar' => 7), array('foo' => 1, 'bar' => 6), array('foo' => 1, 'bar' => 5), array('foo' => 1, 'bar' => 4), array('foo' => 1, 'bar' => 3), array('foo' => 1, 'bar' => 2), array('foo' => 1, 'bar' => 1)));
     $storage = $this->getMock('Flow\\Data\\ObjectStorage');
     $index = new TopKIndex($cache, $storage, 'prefix', array('foo'), array('sort' => 'bar'));
     $result = $index->find(array('foo' => '1'), $queryOptions);
     foreach ($result as $row) {
         $found[] = $row['bar'];
     }
     $this->assertEquals($expect, $found);
 }
 /**
  * @param Header|PostRevision $object
  * @param string[] $old
  * @param array $metadata
  */
 public function onAfterRemove($object, array $old, array $metadata)
 {
     $old['topic_list_id'] = $this->findTopicListId($object, $old, $metadata);
     parent::onAfterRemove($object, $old, $metadata);
 }