/** * Adds a revision to a page, while returning the resuting revision's id * * @param $page WikiPage: page to add the revision to * @param $text string: revisions text * @param $text string: revisions summare * * @throws MWExcepion */ protected function addRevision(Page $page, $text, $summary) { $status = $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle()), $summary); if ($status->isGood()) { $value = $status->getValue(); $revision = $value['revision']; $revision_id = $revision->getId(); $text_id = $revision->getTextId(); if ($revision_id > 0 && $text_id > 0) { return array($revision_id, $text_id); } } throw new MWException("Could not determine revision id (" . $status->getWikiText() . ")"); }
/** * Adds a revision to a page, while returning the resuting revision's id * * @param Page $page Page to add the revision to * @param string $text Revisions text * @param string $summary Revisions summary * @param string $model The model ID (defaults to wikitext) * * @throws MWException * @return array */ protected function addRevision(Page $page, $text, $summary, $model = CONTENT_MODEL_WIKITEXT) { $status = $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle(), $model), $summary); if ($status->isGood()) { $value = $status->getValue(); $revision = $value['revision']; $revision_id = $revision->getId(); $text_id = $revision->getTextId(); if ($revision_id > 0 && $text_id > 0) { return [$revision_id, $text_id]; } } throw new MWException("Could not determine revision id (" . $status->getWikiText(false, false, 'en') . ")"); }