MediaWiki REL1_37
ViewAction.php
Go to the documentation of this file.
1<?php
22
31
32 public function getName() {
33 return 'view';
34 }
35
36 public function onView() {
37 return null;
38 }
39
40 public function needsReadRights() {
41 // Pages in $wgWhitelistRead can be viewed without having the 'read'
42 // right. We rely on Article::view() to properly check read access.
43 return false;
44 }
45
46 public function show() {
47 $config = $this->context->getConfig();
48
49 // Emit deprecated hook warnings.
50 // We do this only in the view action so that it reliably shows up in
51 // the debug toolbar without unduly impacting the performance of API and
52 // ResourceLoader requests.
53 MediaWikiServices::getInstance()->getHookContainer()->emitDeprecationWarnings();
54
55 if (
56 !$config->get( 'DebugToolbar' ) && // don't let this get stuck on pages
57 $this->getWikiPage()->checkTouched() // page exists and is not a redirect
58 ) {
59 // Include any redirect in the last-modified calculation
60 $redirFromTitle = $this->getArticle()->getRedirectedFrom();
61 if ( !$redirFromTitle ) {
62 $touched = $this->getWikiPage()->getTouched();
63 } elseif ( $config->get( 'MaxRedirects' ) <= 1 ) {
64 $touched = max(
65 $this->getWikiPage()->getTouched(),
66 $redirFromTitle->getTouched()
67 );
68 } else {
69 // Don't bother following the chain and getting the max mtime
70 $touched = null;
71 }
72
73 // Send HTTP 304 if the IMS matches or otherwise set expiry/last-modified headers
74 if ( $touched && $this->getOutput()->checkLastModified( $touched ) ) {
75 wfDebug( __METHOD__ . ": done 304" );
76 return;
77 }
78 }
79
80 $this->getArticle()->view();
81 }
82}
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:195
getOutput()
Get the OutputPage being used for this instance.
Definition Action.php:156
getArticle()
Get a Article object.
Definition Action.php:206
An action which just does something, without showing a form first.
MediaWikiServices is the service locator for the application scope of MediaWiki.
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.