/**
  * Update history revision
  */
 private function updateHistory(PostRevision $post, $wiki)
 {
     if ($post->getPrevRevisionId()) {
         $parent = Container::get('storage.post')->get(UUID::create($post->getPrevRevisionId()));
         if ($parent) {
             $this->updateRevision($parent, $wiki);
             $this->updateHistory($parent, $wiki);
         }
     }
 }
 /**
  * While topic's themselves are plaintext and do not contain any references,
  * moderation actions change what references are visible.  When transitioning
  * from or to a generically visible state (unmoderated or locked) the entire
  * topic + summary needs to be re-evaluated.
  *
  * @param Workflow $workflow
  * @param PostRevision $current Topic revision object that was inserted
  * @return array Contains two arrays, first the references to add a second
  *  the references to remove
  * @throws FlowException
  */
 protected function calculateChangesFromTopic(Workflow $workflow, PostRevision $current)
 {
     if ($current->isFirstRevision()) {
         return array(array(), array());
     }
     $previous = $this->storage->get('PostRevision', $current->getPrevRevisionId());
     if (!$previous) {
         throw new FlowException('Expcted previous revision of ' . $current->getPrevRevisionId()->getAlphadecimal());
     }
     $isHidden = self::isHidden($current);
     $wasHidden = self::isHidden($previous);
     if ($isHidden === $wasHidden) {
         return array(array(), array());
     }
     // re-run
     $revisions = $this->collectTopicRevisions($workflow);
     $added = array();
     $removed = array();
     foreach ($revisions as $revision) {
         list($add, $remove) = $this->calculateChangesFromExisting($workflow, $revision, $current);
         $added = array_merge($added, $add);
         $removed = array_merge($removed, $remove);
     }
     return array($added, $removed);
 }