/**
  * @param AbstractRevision $revision Revision object
  * @param array $row Revision row
  * @param array $metadata;
  */
 public function onAfterInsert($revision, array $row, array $metadata)
 {
     global $wgRCFeeds;
     // No action on imported revisions
     if (isset($metadata['imported']) && $metadata['imported']) {
         return;
     }
     $action = $revision->getChangeType();
     $revisionId = $revision->getRevisionId()->getAlphadecimal();
     $timestamp = $revision->getRevisionId()->getTimestamp();
     /** @var Workflow $workflow */
     $workflow = $metadata['workflow'];
     $user = $revision->getUser();
     if (!$this->isAllowed($revision, $action)) {
         return;
     }
     $title = $this->getRcTitle($workflow, $revision->getChangeType());
     $attribs = array('rc_namespace' => $title->getNamespace(), 'rc_title' => $title->getDBkey(), 'rc_user' => $row['rev_user_id'], 'rc_user_text' => $this->usernames->get(wfWikiId(), $row['rev_user_id'], $row['rev_user_ip']), 'rc_type' => RC_FLOW, 'rc_source' => self::SRC_FLOW, 'rc_minor' => 0, 'rc_bot' => 0, 'rc_patrolled' => $user->isAllowed('autopatrol') ? 1 : 0, 'rc_old_len' => $revision->getPreviousContentLength(), 'rc_new_len' => $revision->getContentLength(), 'rc_this_oldid' => 0, 'rc_last_oldid' => 0, 'rc_log_type' => null, 'rc_params' => serialize(array('flow-workflow-change' => array('action' => $action, 'revision_type' => get_class($revision), 'revision' => $revisionId, 'workflow' => $workflow->getId()->getAlphadecimal()))), 'rc_cur_id' => 0, 'rc_comment' => '', 'rc_timestamp' => $timestamp, 'rc_deleted' => 0);
     $rc = $this->rcFactory->newFromRow((object) $attribs);
     $rc->save(true);
     // Insert into db
     $feeds = $wgRCFeeds;
     // Override the IRC formatter with our own formatter
     foreach (array_keys($feeds) as $name) {
         $feeds[$name]['original_formatter'] = $feeds[$name]['formatter'];
         $feeds[$name]['formatter'] = $this->ircFormatter;
     }
     // pre-load the irc formatter which will be triggered via hook
     $this->ircFormatter->associate($rc, array('revision' => $revision) + $metadata);
     // run the feeds/irc/etc external notifications
     $rc->notifyRCFeeds($feeds);
 }
 /**
  * @param IContextSource $context
  * @param AbstractRevision $newRevision
  * @param AbstractRevision|null $oldRevision
  * @param Title $title
  * @return Status
  */
 public function validate(IContextSource $context, AbstractRevision $newRevision, AbstractRevision $oldRevision = null, Title $title)
 {
     $vars = \AbuseFilter::getEditVars($title);
     $vars->addHolders(\AbuseFilter::generateUserVars($this->user), \AbuseFilter::generateTitleVars($title, 'ARTICLE'));
     $vars->setVar('ACTION', $newRevision->getChangeType());
     /*
      * This should not roundtrip to Parsoid; AbuseFilter checks will be
      * performed upon submitting new content, and content is always
      * submitted in wikitext. It will only be transformed once it's being
      * saved to DB.
      */
     $vars->setLazyLoadVar('new_wikitext', 'FlowRevisionContent', array('revision' => $newRevision));
     $vars->setLazyLoadVar('new_size', 'length', array('length-var' => 'new_wikitext'));
     /*
      * This may roundtrip to Parsoid if content is stored in HTML.
      * Since the variable is lazy-loaded, it will not roundtrip unless the
      * variable is actually used.
      */
     $vars->setLazyLoadVar('old_wikitext', 'FlowRevisionContent', array('revision' => $oldRevision));
     $vars->setLazyLoadVar('old_size', 'length', array('length-var' => 'old_wikitext'));
     return \AbuseFilter::filterAction($vars, $title, $this->group);
 }
 /**
  * @param AbstractRevision $revision
  * @return bool
  */
 private function excludeFromHistory(AbstractRevision $revision)
 {
     return (bool) $this->actions->getValue($revision->getChangeType(), 'exclude_from_history');
 }
 /**
  * Build api properties defined in FlowActions for this change type
  *
  * This is a fairly expensive function(compared to the other methods in this class).
  * As such its only output when specifically requested
  *
  * @param UUID $workflowId
  * @param AbstractRevision $revision
  * @param IContextSource $ctx
  * @param FormatterRow|null $row
  * @return array
  */
 public function buildProperties(UUID $workflowId, AbstractRevision $revision, IContextSource $ctx, FormatterRow $row = null)
 {
     if ($this->includeProperties === false) {
         return array();
     }
     $changeType = $revision->getChangeType();
     $actions = $this->permissions->getActions();
     $params = $actions->getValue($changeType, 'history', 'i18n-params');
     if (!$params) {
         // should we have a sigil for i18n with no parameters?
         wfDebugLog('Flow', __METHOD__ . ": No i18n params for changeType {$changeType} on " . $revision->getRevisionId()->getAlphadecimal());
         return array();
     }
     $res = array('_key' => $actions->getValue($changeType, 'history', 'i18n-message'));
     foreach ($params as $param) {
         $res[$param] = $this->processParam($param, $revision, $workflowId, $ctx, $row);
     }
     return $res;
 }
 /**
  * @param AbstractRevision $revision
  * @return bool
  */
 private function excludeFromContributions(AbstractRevision $revision)
 {
     return (bool) $this->actions->getValue($revision->getChangeType(), 'exclude_from_contributions');
 }
 /**
  * Decides if the given abstract revision needs its prior revision for formatting
  * @param AbstractRevision $revision
  * @return boolean true when the previous revision to this should be loaded
  */
 protected function needsPreviousRevision(AbstractRevision $revision)
 {
     // crappy special case needs the previous object so it can show the title
     // but only when outputting a full history api result(we don't know that here)
     return $revision instanceof PostRevision && $revision->getChangeType() === 'edit-title';
 }