/**
  * Prepare change attributes for the given EntityChange. This can be used to avoid
  * re-calculating these attributes for each target page, when processing a change
  * with respect to a batch of affected target pages.
  *
  * @param EntityChange $change
  *
  * @return array Associative array of prepared change attributes, for use with the
  *      $preparedAttribs of newRecentChange().
  */
 public function prepareChangeAttributes(EntityChange $change)
 {
     $rcinfo = $change->getMetadata();
     $fields = $change->getFields();
     $fields['entity_type'] = $change->getEntityId()->getEntityType();
     if (isset($fields['info']['changes'])) {
         $changesForComment = $fields['info']['changes'];
     } else {
         $changesForComment = array($change);
     }
     $comment = $this->getEditCommentMulti($changesForComment);
     unset($fields['info']);
     $metadata = array_merge($fields, $rcinfo);
     $isBot = false;
     if (array_key_exists('bot', $metadata)) {
         $isBot = $metadata['bot'];
     }
     // compatibility
     if (array_key_exists('user_text', $metadata)) {
         $userText = $metadata['user_text'];
     } elseif (array_key_exists('rc_user_text', $metadata)) {
         $userText = $metadata['rc_user_text'];
     } else {
         $userText = '';
     }
     $time = isset($metadata['time']) ? $metadata['time'] : wfTimestamp(TS_MW);
     $params = array('wikibase-repo-change' => $metadata);
     return array('rc_user' => 0, 'rc_user_text' => $userText, 'rc_comment' => $comment, 'rc_type' => RC_EXTERNAL, 'rc_minor' => true, 'rc_bot' => $isBot, 'rc_patrolled' => true, 'rc_params' => serialize($params), 'rc_timestamp' => $time, 'rc_log_type' => null, 'rc_log_action' => '', 'rc_source' => self::SRC_WIKIBASE, 'rc_deleted' => false);
 }
 private function combineChanges(EntityChange $first, EntityChange $last)
 {
     $firstmeta = $first->getMetadata();
     $lastmeta = $last->getMetadata();
     return $this->makeChange(array('id' => null, 'type' => $first->getField('type'), 'time' => $last->getField('time'), 'object_id' => $last->getField('object_id'), 'revision_id' => $last->getField('revision_id'), 'user_id' => $last->getField('user_id'), 'info' => array('metadata' => array('bot' => 0, 'comment' => $lastmeta['comment'], 'parent_id' => $firstmeta['parent_id']))));
 }