Merge "Use DerivativeContext in ApiVisualEditorEdit"

This commit is contained in:
jenkins-bot 2019-03-04 19:09:19 +00:00 committed by Gerrit Code Review
commit 476ffbba68

View file

@ -412,8 +412,10 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
if ( class_exists( FlaggablePageView::class ) ) { if ( class_exists( FlaggablePageView::class ) ) {
$view = FlaggablePageView::singleton(); $view = FlaggablePageView::singleton();
$originalRequest = $view->getContext()->getRequest(); $originalContext = $view->getContext();
$originalTitle = RequestContext::getMain()->getTitle(); $originalTitle = RequestContext::getMain()->getTitle();
$newContext = new DerivativeContext( $originalContext );
// Defeat !$this->isPageView( $request ) || $request->getVal( 'oldid' ) check in setPageContent // Defeat !$this->isPageView( $request ) || $request->getVal( 'oldid' ) check in setPageContent
$newRequest = new DerivativeRequest( $newRequest = new DerivativeRequest(
$this->getRequest(), $this->getRequest(),
@ -424,7 +426,9 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
'action' => 'view' 'action' => 'view'
] + $this->getRequest()->getValues() ] + $this->getRequest()->getValues()
); );
$view->getContext()->setRequest( $newRequest ); $newContext->setRequest( $newRequest );
$newContext->setTitle( $title );
$view->setContext( $newContext );
RequestContext::getMain()->setTitle( $title ); RequestContext::getMain()->setTitle( $title );
// The two parameters here are references but we don't care // The two parameters here are references but we don't care
@ -433,7 +437,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
$useParserCache = null; $useParserCache = null;
$view->setPageContent( $outputDone, $useParserCache ); $view->setPageContent( $outputDone, $useParserCache );
$view->displayTag(); $view->displayTag();
$view->getContext()->setRequest( $originalRequest ); $view->setContext( $originalContext );
RequestContext::getMain()->setTitle( $originalTitle ); RequestContext::getMain()->setTitle( $originalTitle );
} }