MediaWiki master
ViewAction.php
Go to the documentation of this file.
1<?php
23
32
33 public function getName() {
34 return 'view';
35 }
36
37 public function onView() {
38 return null;
39 }
40
41 public function needsReadRights() {
42 // Pages in $wgWhitelistRead can be viewed without having the 'read'
43 // right. We rely on Article::view() to properly check read access.
44 return false;
45 }
46
47 public function show() {
48 $config = $this->context->getConfig();
49
50 // Emit deprecated hook warnings.
51 // We do this only in the view action so that it reliably shows up in
52 // the debug toolbar without unduly impacting the performance of API and
53 // ResourceLoader requests.
54 MediaWikiServices::getInstance()->getHookContainer()->emitDeprecationWarnings();
55
56 if (
57 !$config->get( MainConfigNames::DebugToolbar ) && // don't let this get stuck on pages
58 $this->getWikiPage()->checkTouched() // page exists and is not a redirect
59 ) {
60 // Include any redirect in the last-modified calculation
61 $redirFromTitle = $this->getArticle()->getRedirectedFrom();
62 if ( !$redirFromTitle ) {
63 $touched = $this->getWikiPage()->getTouched();
64 } else {
65 $touched = max(
66 $this->getWikiPage()->getTouched(),
67 $redirFromTitle->getTouched()
68 );
69 }
70
71 // Send HTTP 304 if the IMS matches or otherwise set expiry/last-modified headers
72 if ( $touched && $this->getOutput()->checkLastModified( $touched ) ) {
73 wfDebug( __METHOD__ . ": done 304" );
74 return;
75 }
76 }
77
78 $this->getArticle()->view();
79 }
80}
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
getWikiPage()
Get a WikiPage object.
Definition Action.php:193
getOutput()
Get the OutputPage being used for this instance.
Definition Action.php:144
getArticle()
Get a Article object.
Definition Action.php:204
An action which just does something, without showing a form first.
A class containing constants representing the names of configuration variables.
Service locator for MediaWiki core services.
An action that views article content.
getName()
Return the name of the action this object responds to.
needsReadRights()
Indicates whether this action requires read rights.
onView()
Show something on GET request.