jenkins-bot has submitted this change and it was merged.

Change subject: Set the wiki page on the derivative request
......................................................................


Set the wiki page on the derivative request

ApiMobileView#getFilePage is a hack to get the mobile-formatted HTML of
a page in the File namespace. It does this by dispatching an view action
on the associated file page with a request context derived from the API
request context.

ExtMobileFormatter::DOMParse retrieves the HTML to format from the wiki
page associated with the request context. However, #getFilePage wasn't
associating a wiki page with the request context.
DerivativeContext#getWikiPage will fall back to
RequestContext#getWikiPage, which is initialised with a known bad title,
which causes an exception to be thrown.

Set the wiki page on the derivative request context to that associated
with the file page to stop the exception being thrown.

Bug: T123821
Change-Id: I55cf5d5d1d04f4ed6514c4cd1448cce75da8ccb5
(cherry picked from commit 2b151d63419a2fa50c410649c6332fc0f00cbd26)
---
M includes/api/ApiMobileView.php
1 file changed, 10 insertions(+), 0 deletions(-)

Approvals:
  Alex Monk: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/api/ApiMobileView.php b/includes/api/ApiMobileView.php
index e73ade3..c68c77f 100644
--- a/includes/api/ApiMobileView.php
+++ b/includes/api/ApiMobileView.php
@@ -615,9 +615,19 @@
                $context = new DerivativeContext( $this->getContext() );
                $context->setTitle( $title );
                $context->setOutput( new OutputPage( $context ) );
+
                $page = new ImagePage( $title );
                $page->setContext( $context );
+
+               // T123821: Without setting the wiki page on the derivative 
context,
+               // DerivativeContext#getWikiPage will (eventually) fall back to
+               // RequestContext#getWikiPage. Here, the request context is 
distinct from the
+               // derivative context and deliberately constructed with a bad 
title in the prelude
+               // of api.php.
+               $context->setWikiPage( $page->getPage() );
+
                $page->view();
+
                $html = $context->getOutput()->getHTML();
 
                return $html;

-- 
To view, visit https://gerrit.wikimedia.org/r/264973
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I55cf5d5d1d04f4ed6514c4cd1448cce75da8ccb5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: wmf/1.27.0-wmf.10
Gerrit-Owner: BryanDavis <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to