public static function onIRCLineURLProvider()
 {
     // data providers do not run in the same context as the actual test, as such we
     // can't create Title objects because they can have the wrong wikiID.  Instead we
     // pass closures into the test that create the objects within the correct context.
     $newHeader = function (User $user) {
         $title = Title::newFromText('Talk:Hook_test');
         $workflow = Container::get('factory.loader.workflow')->createWorkflowLoader($title)->getWorkflow();
         $header = Header::create($workflow, $user, 'header content', 'wikitext');
         $metadata = array('workflow' => $workflow, 'revision' => $header);
         /** @var OccupationController $occupationController */
         $occupationController = Container::get('occupation_controller');
         // make sure user has rights to create board
         $user->mRights = array_merge($user->getRights(), array('flow-create-board'));
         $occupationController->allowCreation($title, $user);
         $occupationController->ensureFlowRevision(new \Article($title), $workflow);
         Container::get('storage')->put($workflow, $metadata);
         return $metadata;
     };
     $freshTopic = function (User $user) {
         $title = Title::newFromText('Talk:Hook_test');
         $boardWorkflow = Container::get('factory.loader.workflow')->createWorkflowLoader($title)->getWorkflow();
         $topicWorkflow = Workflow::create('topic', $boardWorkflow->getArticleTitle());
         $topicList = TopicListEntry::create($boardWorkflow, $topicWorkflow);
         $topicTitle = PostRevision::create($topicWorkflow, $user, 'some content', 'wikitext');
         $metadata = array('workflow' => $topicWorkflow, 'board-workflow' => $boardWorkflow, 'topic-title' => $topicTitle, 'revision' => $topicTitle);
         /** @var OccupationController $occupationController */
         $occupationController = Container::get('occupation_controller');
         // make sure user has rights to create board
         $user->mRights = array_merge($user->getRights(), array('flow-create-board'));
         $occupationController->allowCreation($title, $user);
         $occupationController->ensureFlowRevision(new \Article($title), $boardWorkflow);
         $storage = Container::get('storage');
         $storage->put($boardWorkflow, $metadata);
         $storage->put($topicWorkflow, $metadata);
         $storage->put($topicList, $metadata);
         $storage->put($topicTitle, $metadata);
         return $metadata;
     };
     $replyToTopic = function (User $user) use($freshTopic) {
         $metadata = $freshTopic($user);
         $firstPost = $metadata['topic-title']->reply($metadata['workflow'], $user, 'ffuts dna ylper', 'wikitext');
         $metadata = array('first-post' => $firstPost, 'revision' => $firstPost) + $metadata;
         Container::get('storage.post')->put($firstPost, $metadata);
         return $metadata;
     };
     return array(array('Freshly created topic', $freshTopic, array('action' => 'history')), array('Reply to topic', $replyToTopic, array('action' => 'history')), array('Edit topic title', function ($user) use($freshTopic) {
         $metadata = $freshTopic($user);
         $title = $metadata['workflow']->getArticleTitle();
         return array('revision' => $metadata['revision']->newNextRevision($user, 'gnihtemos gnihtemos', 'wikitext', 'edit-title', $title)) + $metadata;
     }, array('action' => 'compare-post-revisions')), array('Edit post', function ($user) use($replyToTopic) {
         $metadata = $replyToTopic($user);
         $title = $metadata['workflow']->getArticleTitle();
         return array('revision' => $metadata['revision']->newNextRevision($user, 'IT\'S CAPS LOCKS DAY!', 'wikitext', 'edit-post', $title)) + $metadata;
     }, array('action' => 'compare-post-revisions')), array('Edit board header', function ($user) use($newHeader) {
         $metadata = $newHeader($user);
         $title = $metadata['workflow']->getArticleTitle();
         return array('revision' => $metadata['revision']->newNextRevision($user, 'STILL CAPS LOCKS DAY!', 'wikitext', 'edit-header', $title)) + $metadata;
     }, array('action' => 'compare-header-revisions')), array('Moderate a post', function ($user) use($replyToTopic) {
         $metadata = $replyToTopic($user);
         return array('revision' => $metadata['revision']->moderate($user, $metadata['revision']::MODERATED_DELETED, 'delete-post', 'something about cruise control')) + $metadata;
     }, array('action' => 'history')), array('Moderate a topic', function ($user) use($freshTopic) {
         $metadata = $freshTopic($user);
         return array('revision' => $metadata['revision']->moderate($user, $metadata['revision']::MODERATED_HIDDEN, 'hide-topic', 'adorable kittens')) + $metadata;
     }, array('action' => 'history')));
 }
 protected function validateFirstRevision()
 {
     if (!$this->permissions->isRevisionAllowed(null, 'create-header') || !$this->permissions->isBoardAllowed($this->workflow, 'create-header')) {
         $this->addError('permissions', $this->context->msg('flow-error-not-allowed'));
         return;
     }
     if (isset($this->submitted['prev_revision']) && $this->submitted['prev_revision']) {
         // User submitted a previous revision, but we couldn't find one.  This is likely
         // an internal error and not a user error, consider better handling
         // is this even worth checking?
         $this->addError('prev_revision', $this->context->msg('flow-error-prev-revision-does-not-exist'));
         return;
     }
     $this->newRevision = Header::create($this->workflow, $this->context->getUser(), $this->submitted['content'], isset($this->submitted['format']) ? $this->submitted['format'] : 'wikitext', 'create-header');
     if (!$this->checkSpamFilters(null, $this->newRevision)) {
         return;
     }
 }
 /**
  * @param PageImportState $pageState
  * @param IImportHeader   $importHeader
  */
 public function importHeader(PageImportState $pageState, IImportHeader $importHeader)
 {
     $pageState->logger->info('Importing header');
     if (!$importHeader->getRevisions()->valid()) {
         $pageState->logger->info('no revisions located for header');
         // No revisions
         return;
     }
     $existingId = $pageState->getImportedId($importHeader);
     if ($existingId && $pageState->getTopRevision('Header', $existingId)) {
         $pageState->logger->info('header previously imported');
         return;
     }
     $revisions = $this->importObjectWithHistory($importHeader, function (IObjectRevision $rev) use($pageState) {
         return Header::create($pageState->boardWorkflow, $pageState->createUser($rev->getAuthor()), $rev->getText(), 'wikitext', 'create-header');
     }, 'edit-header', $pageState, $pageState->boardWorkflow->getArticleTitle());
     $pageState->put($revisions, array('workflow' => $pageState->boardWorkflow));
     $pageState->recordAssociation(reset($revisions)->getCollectionId(), $importHeader);
     $pageState->logger->info('Imported ' . count($revisions) . ' revisions for header');
 }