/**
  * Merges the content of the first item into the second and creates a redirect if the first item
  * is empty after the merge.
  *
  * @param ItemId $fromId
  * @param ItemId $toId
  * @param string[] $ignoreConflicts The kinds of conflicts to ignore
  * @param string|null $summary
  * @param bool $bot Mark the edit as bot edit
  *
  * @return array A list of exactly two EntityRevision objects and a boolean. The first
  *  EntityRevision object represents the modified source item, the second one represents the
  *  modified target item. The boolean indicates whether the redirect was successful.
  *
  * @throws ItemMergeException
  */
 public function mergeItems(ItemId $fromId, ItemId $toId, array $ignoreConflicts = array(), $summary = null, $bot = false)
 {
     $this->checkPermissions($fromId);
     $this->checkPermissions($toId);
     /**
      * @var Item $fromItem
      * @var Item $toItem
      */
     $fromItem = $this->loadEntity($fromId);
     $toItem = $this->loadEntity($toId);
     $this->validateEntities($fromItem, $toItem);
     // strip any bad values from $ignoreConflicts
     $ignoreConflicts = array_intersect($ignoreConflicts, ChangeOpsMerge::$conflictTypes);
     try {
         $changeOps = $this->changeOpFactory->newMergeOps($fromItem, $toItem, $ignoreConflicts);
         $changeOps->apply();
     } catch (ChangeOpException $e) {
         throw new ItemMergeException($e->getMessage(), 'failed-modify', $e);
     }
     $result = $this->attemptSaveMerge($fromItem, $toItem, $summary, $bot);
     $redirected = false;
     if ($this->isEmpty($fromId)) {
         $this->interactorRedirect->createRedirect($fromId, $toId, $bot);
         $redirected = true;
     }
     array_push($result, $redirected);
     return $result;
 }
 /**
  * @param EntityId $fromId
  * @param EntityId $toId
  */
 private function redirectEntity(EntityId $fromId, EntityId $toId)
 {
     $this->tokenCheck->checkRequestToken($this->getRequest(), 'wpEditToken');
     $this->interactor->createRedirect($fromId, $toId, false);
     $this->getOutput()->addWikiMsg('wikibase-redirectentity-success', $fromId->getSerialization(), $toId->getSerialization());
 }
 /**
  * @param EntityId $fromId
  * @param EntityId $toId
  * @param bool $bot Whether the edit should be marked as bot
  * @param ApiResult $result The result object to report the result to.
  *
  * @throws RedirectCreationException
  */
 private function createRedirect(EntityId $fromId, EntityId $toId, $bot, ApiResult $result)
 {
     $this->interactor->createRedirect($fromId, $toId, $bot);
     $result->addValue(null, 'success', 1);
     $result->addValue(null, 'redirect', $toId->getSerialization());
 }