protected function doStore(EditPage $editor)
 {
     $title = $editor->getTitle();
     // If they used redlink=1 and the page exists, redirect to the main article and send notice
     if ($this->getRequest()->getBool('redlink') && $title->exists()) {
         $this->logMessage(wfMessage('sf_autoedit_redlinkexists')->parse(), self::WARNING);
     }
     $permErrors = $title->getUserPermissionsErrors('edit', $this->getUser());
     // if this title needs to be created, user needs create rights
     if (!$title->exists()) {
         $permErrors = array_merge($permErrors, wfArrayDiff2($title->getUserPermissionsErrors('create', $this->getUser()), $permErrors));
     }
     if ($permErrors) {
         // Auto-block user's IP if the account was "hard" blocked
         $this->getUser()->spreadAnyEditBlock();
         foreach ($permErrors as $error) {
             $this->logMessage(call_user_func_array('wfMessage', $error)->parse());
         }
         return;
     }
     $resultDetails = false;
     # Allow bots to exempt some edits from bot flagging
     $bot = $this->getUser()->isAllowed('bot') && $editor->bot;
     $request = $editor->sfFauxRequest;
     if ($editor->tokenOk($request)) {
         $ctx = RequestContext::getMain();
         $tempTitle = $ctx->getTitle();
         $ctx->setTitle($title);
         $status = $editor->internalAttemptSave($resultDetails, $bot);
         $ctx->setTitle($tempTitle);
     } else {
         throw new MWException(wfMessage('session_fail_preview')->parse());
     }
     switch ($status->value) {
         case EditPage::AS_HOOK_ERROR_EXPECTED:
             // A hook function returned an error
             // show normal Edit page
             // remove Preview and Diff standard buttons from editor page
             Hooks::register('EditPageBeforeEditButtons', function (&$editor, &$buttons, &$tabindex) {
                 foreach (array_keys($buttons) as $key) {
                     if ($key !== 'save') {
                         unset($buttons[$key]);
                     }
                 }
             });
             // Context title needed for correct Cancel link
             $editor->setContextTitle($title);
             $editor->showEditForm();
             return false;
             // success
         // success
         case EditPage::AS_CONTENT_TOO_BIG:
             // Content too big (> $wgMaxArticleSize)
         // Content too big (> $wgMaxArticleSize)
         case EditPage::AS_ARTICLE_WAS_DELETED:
             // article was deleted while editting and param wpRecreate == false or form was not posted
         // article was deleted while editting and param wpRecreate == false or form was not posted
         case EditPage::AS_CONFLICT_DETECTED:
             // (non-resolvable) edit conflict
         // (non-resolvable) edit conflict
         case EditPage::AS_SUMMARY_NEEDED:
             // no edit summary given and the user has forceeditsummary set and the user is not editting in his own userspace or talkspace and wpIgnoreBlankSummary == false
         // no edit summary given and the user has forceeditsummary set and the user is not editting in his own userspace or talkspace and wpIgnoreBlankSummary == false
         case EditPage::AS_TEXTBOX_EMPTY:
             // user tried to create a new section without content
         // user tried to create a new section without content
         case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
             // article is too big (> $wgMaxArticleSize), after merging in the new section
         // article is too big (> $wgMaxArticleSize), after merging in the new section
         case EditPage::AS_END:
             // WikiPage::doEdit() was unsuccessfull
             throw new MWException(wfMessage('sf_autoedit_fail', $this->mOptions['target'])->parse());
         case EditPage::AS_HOOK_ERROR:
             // Article update aborted by a hook function
             $this->logMessage('Article update aborted by a hook function', self::DEBUG);
             return false;
             // success
             // TODO: This error code only exists from 1.21 onwards. It is
             // suitably handled by the default branch, but really should get its
             // own branch. Uncomment once compatibility to pre1.21 is dropped.
             //			case EditPage::AS_PARSE_ERROR: // can't parse content
             //
             //				throw new MWException( $status->getHTML() );
             //				return true; // fail
         // success
         // TODO: This error code only exists from 1.21 onwards. It is
         // suitably handled by the default branch, but really should get its
         // own branch. Uncomment once compatibility to pre1.21 is dropped.
         //			case EditPage::AS_PARSE_ERROR: // can't parse content
         //
         //				throw new MWException( $status->getHTML() );
         //				return true; // fail
         case EditPage::AS_SUCCESS_NEW_ARTICLE:
             // Article successfully created
             $query = $resultDetails['redirect'] ? 'redirect=no' : '';
             $anchor = isset($resultDetails['sectionanchor']) ? $resultDetails['sectionanchor'] : '';
             $this->getOutput()->redirect($title->getFullURL($query) . $anchor);
             $this->getResult()->addValue(NULL, 'redirect', $title->getFullURL($query) . $anchor);
             return false;
             // success
         // success
         case EditPage::AS_SUCCESS_UPDATE:
             // Article successfully updated
             $extraQuery = '';
             $sectionanchor = $resultDetails['sectionanchor'];
             // Give extensions a chance to modify URL query on update
             Hooks::run('ArticleUpdateBeforeRedirect', array($editor->getArticle(), &$sectionanchor, &$extraQuery));
             if ($resultDetails['redirect']) {
                 if ($extraQuery == '') {
                     $extraQuery = 'redirect=no';
                 } else {
                     $extraQuery = 'redirect=no&' . $extraQuery;
                 }
             }
             $this->getOutput()->redirect($title->getFullURL($extraQuery) . $sectionanchor);
             $this->getResult()->addValue(NULL, 'redirect', $title->getFullURL($extraQuery) . $sectionanchor);
             return false;
             // success
         // success
         case EditPage::AS_BLANK_ARTICLE:
             // user tried to create a blank page
             $this->logMessage('User tried to create a blank page', self::DEBUG);
             $this->getOutput()->redirect($editor->getContextTitle()->getFullURL());
             $this->getResult()->addValue(NULL, 'redirect', $editor->getContextTitle()->getFullURL());
             return false;
             // success
         // success
         case EditPage::AS_SPAM_ERROR:
             // summary contained spam according to one of the regexes in $wgSummarySpamRegex
             $match = $resultDetails['spam'];
             if (is_array($match)) {
                 $match = $this->getLanguage()->listToText($match);
             }
             throw new MWException(wfMessage('spamprotectionmatch', wfEscapeWikiText($match))->parse());
             // FIXME: Include better error message
         // FIXME: Include better error message
         case EditPage::AS_BLOCKED_PAGE_FOR_USER:
             // User is blocked from editting editor page
             throw new UserBlockedError($this->getUser()->getBlock());
         case EditPage::AS_IMAGE_REDIRECT_ANON:
             // anonymous user is not allowed to upload (User::isAllowed('upload') == false)
         // anonymous user is not allowed to upload (User::isAllowed('upload') == false)
         case EditPage::AS_IMAGE_REDIRECT_LOGGED:
             // logged in user is not allowed to upload (User::isAllowed('upload') == false)
             throw new PermissionsError('upload');
         case EditPage::AS_READ_ONLY_PAGE_ANON:
             // editor anonymous user is not allowed to edit editor page
         // editor anonymous user is not allowed to edit editor page
         case EditPage::AS_READ_ONLY_PAGE_LOGGED:
             // editor logged in user is not allowed to edit editor page
             throw new PermissionsError('edit');
         case EditPage::AS_READ_ONLY_PAGE:
             // wiki is in readonly mode (wfReadOnly() == true)
             throw new ReadOnlyError();
         case EditPage::AS_RATE_LIMITED:
             // rate limiter for action 'edit' was tripped
             throw new ThrottledError();
         case EditPage::AS_NO_CREATE_PERMISSION:
             // user tried to create editor page, but is not allowed to do that ( Title->usercan('create') == false )
             $permission = $title->isTalkPage() ? 'createtalk' : 'createpage';
             throw new PermissionsError($permission);
         default:
             // We don't recognize $status->value. The only way that can happen
             // is if an extension hook aborted from inside ArticleSave.
             // Render the status object into $editor->hookError
             $editor->hookError = '<div class="error">' . $status->getWikitext() . '</div>';
             throw new MWException($status->getHTML());
     }
 }