/** * @dataProvider provideGetExistingReferences */ public function testGetExistingReferences(array $references) { list($workflow, $revision, $title) = $this->getBlandTestObjects(); $references = $this->expandReferences($workflow, $revision, $references); $this->storage->multiPut($references); $foundReferences = $this->recorder->getExistingReferences($revision->getRevisionType(), $revision->getCollectionId()); $this->assertReferenceListsEqual($references, $foundReferences); }
public function onAfterInsert($revision, array $new, array $metadata) { if (!isset($metadata['workflow'])) { return; } if (!$revision instanceof AbstractRevision) { throw new InvalidDataException('ReferenceRecorder can only attach to AbstractRevision storage'); } $workflow = $metadata['workflow']; if ($revision instanceof PostRevision && $revision->isTopicTitle()) { list($added, $removed) = $this->calculateChangesFromTopic($workflow, $revision); } else { list($added, $removed) = $this->calculateChangesFromExisting($workflow, $revision); } $this->storage->multiPut($added); $this->storage->multiRemove($removed); // Data updates $this->linksTableUpdater->doUpdate($workflow); }
/** * Overwriting default writer because I want to use Flow storage methods so * the updates also affect cache, not just DB. * * @param array[] $updates */ public function write(array $updates) { /* * from: * array( * 'primaryKey' => array( 'workflow_id' => $id ), * 'updates' => array( 'workflow_last_update_timestamp' => $timestamp ), * ) * to: * array( $id => $timestamp ); */ $timestamps = array_combine($this->arrayColumn($this->arrayColumn($updates, 'primaryKey'), 'workflow_id'), $this->arrayColumn($this->arrayColumn($updates, 'changes'), 'workflow_last_update_timestamp')); /** @var UUID[] $uuids */ $uuids = array_map(array('Flow\\Model\\UUID', 'create'), array_keys($timestamps)); /** @var Workflow[] $workflows */ $workflows = $this->storage->getMulti('Workflow', $uuids); foreach ($workflows as $workflow) { $timestamp = $timestamps[$workflow->getId()->getBinary()]; $workflow->updateLastModified(UUID::getComparisonUUID($timestamp)); } $this->storage->multiPut($workflows); // prevent memory from filling up $this->storage->clear(); wfWaitForSlaves(false, false, $this->clusterName); }
/** * @param object|object[] $object * @param array $metadata */ public function put($object, array $metadata) { $metadata['imported'] = true; if (is_array($object)) { $this->storage->multiPut($object, $metadata); } else { $this->storage->put($object, $metadata); } }