// may still be a wikipage redirect to another article or URL.
$article = $this->initializeArticle();
if ( is_object( $article ) ) {
- $url = $request->getFullRequestURL(); // requested URL
- if (
- $request->getMethod() === 'GET' &&
- $url === $article->getTitle()->getCanonicalURL() &&
- $article->checkTouched() &&
- $output->checkLastModified( $article->getTouched() )
- ) {
- wfDebug( __METHOD__ . ": done 304\n" );
- return;
- }
$this->performAction( $article, $requestTitle );
} elseif ( is_string( $article ) ) {
$output->redirect( $article );
}
public function show() {
+ $config = $this->context->getConfig();
+
+ if (
+ $config->get( 'DebugToolbar' ) == false && // don't let this get stuck on pages
+ $this->page->checkTouched() // page exists and is not a redirect
+ ) {
+ // Include any redirect in the last-modified calculation
+ $redirFromTitle = $this->page->getRedirectedFrom();
+ if ( !$redirFromTitle ) {
+ $touched = $this->page->getTouched();
+ } elseif ( $config->get( 'MaxRedirects' ) <= 1 ) {
+ $touched = max( $this->page->getTouched(), $redirFromTitle->getTouched() );
+ } else {
+ // Don't bother following the chain and getting the max mtime
+ $touched = null;
+ }
+
+ // Send HTTP 304 if the IMS matches or otherwise set expiry/last-modified headers
+ if ( $touched && $this->getOutput()->checkLastModified( $touched ) ) {
+ wfDebug( __METHOD__ . ": done 304\n" );
+ return;
+ }
+ }
+
$this->page->view();
}
}
return $article;
}
+ /**
+ * Get the page this view was redirected from
+ * @return Title|null
+ * @since 1.28
+ */
+ public function getRedirectedFrom() {
+ return $this->mRedirectedFrom;
+ }
+
/**
* Tell the page view functions that this view was redirected
* from another page on the wiki.
* page of the given title.
*/
public function view() {
- global $wgUseFileCache, $wgDebugToolbar, $wgMaxRedirects;
+ global $wgUseFileCache, $wgDebugToolbar;
# Get variables from query string
# As side effect this will load the revision and update the title
# Try client and file cache
if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched() ) {
- # Use the greatest of the page's timestamp or the timestamp of any
- # redirect in the chain (bug 67849)
- $timestamp = $this->mPage->getTouched();
- if ( isset( $this->mRedirectedFrom ) ) {
- $timestamp = max( $timestamp, $this->mRedirectedFrom->getTouched() );
-
- # If there can be more than one redirect in the chain, we have
- # to go through the whole chain too in case an intermediate
- # redirect was changed.
- if ( $wgMaxRedirects > 1 ) {
- $titles = Revision::newFromTitle( $this->mRedirectedFrom )
- ->getContent( Revision::FOR_THIS_USER, $user )
- ->getRedirectChain();
- $thisTitle = $this->getTitle();
- foreach ( $titles as $title ) {
- if ( Title::compare( $title, $thisTitle ) === 0 ) {
- break;
- }
- $timestamp = max( $timestamp, $title->getTouched() );
- }
- }
- }
-
# Try to stream the output from file cache
if ( $wgUseFileCache && $this->tryFileCache() ) {
wfDebug( __METHOD__ . ": done file cache\n" );