From 501bb93e3ed7eb7bcb23348856ed002b4e307dc5 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 15 Nov 2018 15:56:57 +0100 Subject: [PATCH] Make the context page the edited page in EditPages This forces the WikiPage returned by $this->getContext()->getPage() to be the same as $this->page. This seems to be redundant at the moment, but it seems prudent to make sure this does not break. Having two WikiPage instances may cause subtle problems, such as redundant parsing of content during edits. Bug: T205369 Change-Id: I8dd3235ec395fa8772ad810f8b09a098a940ab0c --- includes/EditPage.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 373f6d9bf6..09dc070ca3 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -476,7 +476,15 @@ class EditPage { $this->mArticle = $article; $this->page = $article->getPage(); // model object $this->mTitle = $article->getTitle(); - $this->context = $article->getContext(); + + // Make sure the local context is in sync with other member variables. + // Particularly make sure everything is using the same WikiPage instance. + // This should probably be the case in Article as well, but it's + // particularly important for EditPage, to make use of the in-place caching + // facility in WikiPage::prepareContentForEdit. + $this->context = new DerivativeContext( $article->getContext() ); + $this->context->setWikiPage( $this->page ); + $this->context->setTitle( $this->mTitle ); $this->contentModel = $this->mTitle->getContentModel(); -- 2.20.1