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
* here, there doesn't seem to be any other way to stop calling
* OutputPage::enableSectionEditLinks() and still have it work as it did before.
*/
* 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
/**
* Constructor and clear the article
if ( $outputPage->isPrintable() ) {
$parserOptions->setIsPrintable( true );
$poOptions['enableSectionEditLinks'] = false;
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;
|| !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user )
) {
$poOptions['enableSectionEditLinks'] = false;
public function render() {
$this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
$this->getContext()->getOutput()->setArticleBodyOnly( true );
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->repo = $img->getRepo();
}
$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;
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' );
$out = $this->getContext()->getOutput();
$request = $this->getContext()->getRequest();
$diff = $request->getVal( 'diff' );