X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FEditPage.php;h=f1f0572bacebe83fc6ab632d0baf6b6b0edc202f;hp=d1f874ead7711d9bb64b2a41fce554eb848b2d42;hb=fe94275c8fcfc248a5eae857dde7c5772d993ab5;hpb=15f6eff90c305d405fe4331c8a8dc8caa842e5b3 diff --git a/includes/EditPage.php b/includes/EditPage.php index d1f874ead7..f1f0572bac 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -684,7 +684,10 @@ class EditPage { # checking, etc. if ( 'initial' == $this->formtype || $this->firsttime ) { if ( $this->initialiseForm() === false ) { - $this->noSuchSectionPage(); + $out = $this->context->getOutput(); + if ( $out->getRedirect() === '' ) { // mcrundo hack redirects, don't override it + $this->noSuchSectionPage(); + } return; } @@ -1055,7 +1058,7 @@ class EditPage { $this->sectiontitle = $request->getVal( 'preloadtitle' ); // Once wpSummary isn't being use for setting section titles, we should delete this. $this->summary = $request->getVal( 'preloadtitle' ); - } elseif ( $this->section != 'new' && $request->getVal( 'summary' ) ) { + } elseif ( $this->section != 'new' && $request->getVal( 'summary' ) !== '' ) { $this->summary = $request->getText( 'summary' ); if ( $this->summary !== '' ) { $this->hasPresetSummary = true; @@ -1220,8 +1223,13 @@ class EditPage { !$oldrev->isDeleted( Revision::DELETED_TEXT ) ) { if ( WikiPage::hasDifferencesOutsideMainSlot( $undorev, $oldrev ) ) { - // Cannot yet undo edits that involve anything other the main slot. - $undoMsg = 'main-slot-only'; + // Hack for undo while EditPage can't handle multi-slot editing + $this->context->getOutput()->redirect( $this->mTitle->getFullURL( [ + 'action' => 'mcrundo', + 'undo' => $undo, + 'undoafter' => $undoafter, + ] ) ); + return false; } else { $content = $this->page->getUndoContent( $undorev, $oldrev ); @@ -1681,7 +1689,7 @@ class EditPage { // is if an extension hook aborted from inside ArticleSave. // Render the status object into $this->hookError // FIXME this sucks, we should just use the Status object throughout - $this->hookError = '
' ."\n" . $status->getWikiText() . + $this->hookError = '
' . "\n" . $status->getWikiText() . '
'; return true; } @@ -1774,7 +1782,7 @@ ERROR; if ( $this->summary === '' ) { $cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle ); return $this->context->msg( 'newsectionsummary' ) - ->rawParams( $cleanSectionTitle )->inContentLanguage()->text(); + ->plaintextParams( $cleanSectionTitle )->inContentLanguage()->text(); } } elseif ( $this->summary !== '' ) { $sectionanchor = $this->guessSectionName( $this->summary ); @@ -1782,7 +1790,7 @@ ERROR; # in the revision summary. $cleanSummary = $wgParser->stripSectionName( $this->summary ); return $this->context->msg( 'newsectionsummary' ) - ->rawParams( $cleanSummary )->inContentLanguage()->text(); + ->plaintextParams( $cleanSummary )->inContentLanguage()->text(); } return $this->summary; } @@ -2482,6 +2490,8 @@ ERROR; $displayTitle = isset( $this->mParserOutput ) ? $this->mParserOutput->getDisplayTitle() : false; if ( $displayTitle === false ) { $displayTitle = $contextTitle->getPrefixedText(); + } else { + $out->setDisplayTitle( $displayTitle ); } $out->setPageTitle( $this->context->msg( $msg, $displayTitle ) ); @@ -2861,7 +2871,7 @@ ERROR; $this->autoSumm = md5( '' ); } - $autosumm = $this->autoSumm ?: md5( $this->summary ); + $autosumm = $this->autoSumm !== '' ? $this->autoSumm : md5( $this->summary ); $out->addHTML( Html::hidden( 'wpAutoSummary', $autosumm ) ); $out->addHTML( Html::hidden( 'oldid', $this->oldid ) ); @@ -3778,7 +3788,7 @@ ERROR; /** * Get the last log record of this page being deleted, if ever. This is - * used to detect whether a delete occured during editing. + * used to detect whether a delete occurred during editing. * @return bool|stdClass */ protected function getLastDelete() { @@ -3989,6 +3999,12 @@ ERROR; $parserOptions->setIsPreview( true ); $parserOptions->setIsSectionPreview( !is_null( $this->section ) && $this->section !== '' ); $parserOptions->enableLimitReport(); + + // XXX: we could call $parserOptions->setCurrentRevisionCallback here to force the + // current revision to be null during PST, until setupFakeRevision is called on + // the ParserOptions. Currently, we rely on Parser::getRevisionObject() to ignore + // existing revisions in preview mode. + return $parserOptions; } @@ -4004,9 +4020,14 @@ ERROR; protected function doPreviewParse( Content $content ) { $user = $this->context->getUser(); $parserOptions = $this->getPreviewParserOptions(); + + // NOTE: preSaveTransform doesn't have a fake revision to operate on. + // Parser::getRevisionObject() will return null in preview mode, + // causing the context user to be used for {{subst:REVISIONUSER}}. + // XXX: Alternatively, we could also call setupFakeRevision() a second time: + // once before PST with $content, and then after PST with $pstContent. $pstContent = $content->preSaveTransform( $this->mTitle, $user, $parserOptions ); - $scopedCallback = $parserOptions->setupFakeRevision( - $this->mTitle, $pstContent, $user ); + $scopedCallback = $parserOptions->setupFakeRevision( $this->mTitle, $pstContent, $user ); $parserOutput = $pstContent->getParserOutput( $this->mTitle, null, $parserOptions ); ScopedCallback::consume( $scopedCallback ); return [