From 5f2cb872b587a601a6a07624802e7b56d76e2e95 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 18 Oct 2018 05:06:23 +0200 Subject: [PATCH] ImagePage: Inherit parent's handling for action=render ImagePage::render() was calling parent::view() instead of parent::render(), thus skipping Article::render() entirely. Therefore the logic to disable section edit links (and also, to add an 'X-Robots-Tag: noindex' header) was not being used. This fixes T65891 and T21415 for pages in 'File:' namespace. Bug: T206546 Change-Id: I36ae716c9a363ae29b7a785cc41430301250baba --- includes/page/Article.php | 7 ++++--- includes/page/ImagePage.php | 15 ++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/includes/page/Article.php b/includes/page/Article.php index 803bf0a2b2..36632f0c09 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -120,7 +120,7 @@ class Article implements Page { * here, there doesn't seem to be any other way to stop calling * OutputPage::enableSectionEditLinks() and still have it work as it did before. */ - private $disableSectionEditForRender = false; + protected $viewIsRenderAction = false; /** * Constructor and clear the article @@ -633,7 +633,7 @@ class Article implements Page { if ( $outputPage->isPrintable() ) { $parserOptions->setIsPrintable( true ); $poOptions['enableSectionEditLinks'] = false; - } elseif ( $this->disableSectionEditForRender + } elseif ( $this->viewIsRenderAction || !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user ) ) { $poOptions['enableSectionEditLinks'] = false; @@ -1735,7 +1735,8 @@ class Article implements Page { public function render() { $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' ); $this->getContext()->getOutput()->setArticleBodyOnly( true ); - $this->disableSectionEditForRender = true; + // We later set 'enableSectionEditLinks=false' based on this; also used by ImagePage + $this->viewIsRenderAction = true; $this->view(); } diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php index bf3eaf41d8..1773e16a93 100644 --- a/includes/page/ImagePage.php +++ b/includes/page/ImagePage.php @@ -86,18 +86,15 @@ class ImagePage extends Article { $this->repo = $img->getRepo(); } - /** - * Handler for action=render - * Include body text only; none of the image extras - */ - public function render() { - $this->getContext()->getOutput()->setArticleBodyOnly( true ); - parent::view(); - } - public function view() { global $wgShowEXIF; + // For action=render, include body text only; none of the image extras + if ( $this->viewIsRenderAction ) { + parent::view(); + return; + } + $out = $this->getContext()->getOutput(); $request = $this->getContext()->getRequest(); $diff = $request->getVal( 'diff' ); -- 2.20.1