Make the context page the edited page in EditPages
authordaniel <dkinzler@wikimedia.org>
Thu, 15 Nov 2018 14:56:57 +0000 (15:56 +0100)
committerDaniel Kinzler <dkinzler@wikimedia.org>
Fri, 16 Nov 2018 09:30:12 +0000 (09:30 +0000)
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

index 373f6d9..09dc070 100644 (file)
@@ -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();