/**
  * Save the new version of the given item.
  *
  * @param Item $item
  * @param User $user
  *
  * @return bool
  */
 private function saveChanges(Item $item, User $user)
 {
     $summary = $this->getSummary();
     $itemId = $item->getId();
     $summaryString = $this->summaryFormatter->formatSummary($summary);
     $editEntity = $this->editEntityFactory->newEditEntity($user, $item, true);
     $status = $editEntity->attemptSave($summaryString, EDIT_UPDATE, false, $this->entityStore->isWatching($user, $itemId));
     if (!$status->isOK()) {
         wfDebugLog('UpdateRepo', __FUNCTION__ . ': attemptSave for ' . $itemId->getSerialization() . ' failed: ' . $status->getMessage()->text());
     }
     return $status->isOK();
 }
 /**
  * Attempts to save the new entity content, chile first checking for permissions,
  * edit conflicts, etc. Saving is done via EditEntityHandler::attemptSave().
  *
  * This method automatically takes into account several parameters:
  * * 'bot' for setting the bot flag
  * * 'baserevid' for determining the edit's base revision for conflict resolution
  * * 'token' for the edit token
  *
  * If an error occurs, it is automatically reported and execution of the API module
  * is terminated using the ApiErrorReporter (via handleStatus()). If there were any
  * warnings, they will automatically be included in the API call's output (again, via
  * handleStatus()).
  *
  * @param EntityDocument $entity The entity to save
  * @param string|Summary $summary The edit summary
  * @param int $flags The edit flags (see WikiPage::doEditContent)
  *
  * @throws LogicException if not in write mode
  * @return Status the status of the save operation, as returned by EditEntityHandler::attemptSave()
  * @see  EditEntityHandler::attemptSave()
  */
 public function attemptSaveEntity(EntityDocument $entity, $summary, $flags = 0)
 {
     if (!$this->apiBase->isWriteMode()) {
         // sanity/safety check
         throw new LogicException('attemptSaveEntity() cannot be used by API modules that do not return true from isWriteMode()!');
     }
     if ($summary instanceof Summary) {
         $summary = $this->summaryFormatter->formatSummary($summary);
     }
     $params = $this->apiBase->extractRequestParams();
     $user = $this->apiBase->getContext()->getUser();
     if (isset($params['bot']) && $params['bot'] && $user->isAllowed('bot')) {
         $flags |= EDIT_FORCE_BOT;
     }
     $baseRevisionId = isset($params['baserevid']) ? (int) $params['baserevid'] : null;
     $editEntityHandler = $this->editEntityFactory->newEditEntity($user, $entity, $baseRevisionId);
     $token = $this->evaluateTokenParam($params);
     $status = $editEntityHandler->attemptSave($summary, $flags, $token);
     $this->handleSaveStatus($status);
     return $status;
 }
 /**
  * Saves the entity using the given summary.
  *
  * @param Entity $entity
  * @param Summary $summary
  * @param string $token
  * @param int $flags The edit flags (see WikiPage::doEditContent)
  * @param bool|int $baseRev the base revision, for conflict detection
  *
  * @return Status
  */
 protected function saveEntity(Entity $entity, Summary $summary, $token, $flags = EDIT_UPDATE, $baseRev = false)
 {
     $editEntity = $this->editEntityFactory->newEditEntity($this->getUser(), $entity, $baseRev);
     $status = $editEntity->attemptSave($this->summaryFormatter->formatSummary($summary), $flags, $token);
     return $status;
 }