2012-01-17 19:56:08 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Actions
|
|
|
|
|
*/
|
|
|
|
|
|
2022-04-26 15:48:03 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
2020-04-16 06:20:16 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2013-03-05 15:39:35 +00:00
|
|
|
/**
|
|
|
|
|
* An action that views article content
|
|
|
|
|
*
|
2016-11-23 02:11:01 +00:00
|
|
|
* This is a wrapper that will call Article::view().
|
2013-03-05 15:39:35 +00:00
|
|
|
*
|
|
|
|
|
* @ingroup Actions
|
|
|
|
|
*/
|
2012-01-17 19:56:08 +00:00
|
|
|
class ViewAction extends FormlessAction {
|
|
|
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
|
return 'view';
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-20 15:09:25 +00:00
|
|
|
public function onView() {
|
2012-01-17 19:56:08 +00:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-14 06:30:16 +00:00
|
|
|
public function needsReadRights() {
|
|
|
|
|
// Pages in $wgWhitelistRead can be viewed without having the 'read'
|
|
|
|
|
// right. We rely on Article::view() to properly check read access.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-20 15:09:25 +00:00
|
|
|
public function show() {
|
2016-08-25 00:19:58 +00:00
|
|
|
$config = $this->context->getConfig();
|
|
|
|
|
|
2020-04-16 06:20:16 +00:00
|
|
|
// Emit deprecated hook warnings.
|
|
|
|
|
// We do this only in the view action so that it reliably shows up in
|
|
|
|
|
// the debug toolbar without unduly impacting the performance of API and
|
|
|
|
|
// ResourceLoader requests.
|
|
|
|
|
MediaWikiServices::getInstance()->getHookContainer()->emitDeprecationWarnings();
|
|
|
|
|
|
2016-08-25 00:19:58 +00:00
|
|
|
if (
|
2022-04-26 15:48:03 +00:00
|
|
|
!$config->get( MainConfigNames::DebugToolbar ) && // don't let this get stuck on pages
|
2020-03-26 00:43:50 +00:00
|
|
|
$this->getWikiPage()->checkTouched() // page exists and is not a redirect
|
2016-08-25 00:19:58 +00:00
|
|
|
) {
|
|
|
|
|
// Include any redirect in the last-modified calculation
|
2020-03-26 00:43:50 +00:00
|
|
|
$redirFromTitle = $this->getArticle()->getRedirectedFrom();
|
2016-08-25 00:19:58 +00:00
|
|
|
if ( !$redirFromTitle ) {
|
2020-03-26 00:43:50 +00:00
|
|
|
$touched = $this->getWikiPage()->getTouched();
|
2022-04-11 21:32:11 +00:00
|
|
|
} else {
|
2020-03-26 00:43:50 +00:00
|
|
|
$touched = max(
|
|
|
|
|
$this->getWikiPage()->getTouched(),
|
|
|
|
|
$redirFromTitle->getTouched()
|
|
|
|
|
);
|
2016-08-25 00:19:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send HTTP 304 if the IMS matches or otherwise set expiry/last-modified headers
|
|
|
|
|
if ( $touched && $this->getOutput()->checkLastModified( $touched ) ) {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( __METHOD__ . ": done 304" );
|
2016-08-25 00:19:58 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 00:43:50 +00:00
|
|
|
$this->getArticle()->view();
|
2012-01-17 19:56:08 +00:00
|
|
|
}
|
|
|
|
|
}
|