2011-05-04 17:23:14 +00:00
|
|
|
<?php
|
2006-01-11 09:24:34 +00:00
|
|
|
/**
|
2011-06-28 17:20:16 +00:00
|
|
|
* Helper class for the index.php entry point.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The MediaWiki class is the helper class for the index.php entry point.
|
2010-03-15 23:22:50 +00:00
|
|
|
*
|
|
|
|
|
* @internal documentation reviewed 15 Mar 2010
|
2006-01-11 09:24:34 +00:00
|
|
|
*/
|
Provisional revert of r89406, r89414: reference-related warnings need cleanup before applying code like this
Per CR http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89406#c17545 :
'Here is a third one: Strict Standards: Only variables should be passed by reference in /www/sandwiki/includes/Wiki.php on line 177 '
Offending bit is this:
- SpecialPageFactory::executePath( $this->context->title, $this->context );
+ SpecialPageFactory::executePath( $this->getTitle(), $this->getContext() );
That function demands reference paramters for $title and $context, which is being violated here where we now pass function return values:
public static function executePath( Title &$title, RequestContext &$context, $including = false ) {
The $title does sometimes get replaced within the function body, but $context does not appear to ever be replaced (its *contents* are modified, which does not require passing by reference)
If replacing it is something it should be doing, then we need to be able to replace it upstream presumably, so $this->getTitle() probably isn't appropriate.
The $context probably should have the reference simply removed.
2011-06-03 18:48:59 +00:00
|
|
|
class MediaWiki {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TODO: fold $output, etc, into this
|
2011-09-15 15:19:49 +00:00
|
|
|
* @var IContextSource
|
Provisional revert of r89406, r89414: reference-related warnings need cleanup before applying code like this
Per CR http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89406#c17545 :
'Here is a third one: Strict Standards: Only variables should be passed by reference in /www/sandwiki/includes/Wiki.php on line 177 '
Offending bit is this:
- SpecialPageFactory::executePath( $this->context->title, $this->context );
+ SpecialPageFactory::executePath( $this->getTitle(), $this->getContext() );
That function demands reference paramters for $title and $context, which is being violated here where we now pass function return values:
public static function executePath( Title &$title, RequestContext &$context, $including = false ) {
The $title does sometimes get replaced within the function body, but $context does not appear to ever be replaced (its *contents* are modified, which does not require passing by reference)
If replacing it is something it should be doing, then we need to be able to replace it upstream presumably, so $this->getTitle() probably isn't appropriate.
The $context probably should have the reference simply removed.
2011-06-03 18:48:59 +00:00
|
|
|
*/
|
|
|
|
|
private $context;
|
2011-04-03 21:32:50 +00:00
|
|
|
|
2011-05-04 11:50:34 +00:00
|
|
|
public function request( WebRequest $x = null ){
|
2011-06-21 23:28:50 +00:00
|
|
|
$old = $this->context->getRequest();
|
2011-06-17 10:29:39 +00:00
|
|
|
$this->context->setRequest( $x );
|
2011-06-21 23:28:50 +00:00
|
|
|
return $old;
|
2011-04-03 19:39:39 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-04 11:50:34 +00:00
|
|
|
public function output( OutputPage $x = null ){
|
2011-06-21 23:28:50 +00:00
|
|
|
$old = $this->context->getOutput();
|
2011-06-17 10:29:39 +00:00
|
|
|
$this->context->setOutput( $x );
|
2011-06-21 23:28:50 +00:00
|
|
|
return $old;
|
2011-04-03 19:39:39 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-15 15:19:49 +00:00
|
|
|
public function __construct( IContextSource $context = null ) {
|
2011-06-18 14:50:26 +00:00
|
|
|
if ( !$context ) {
|
|
|
|
|
$context = RequestContext::getMain();
|
|
|
|
|
}
|
2011-06-21 23:28:50 +00:00
|
|
|
|
Provisional revert of r89406, r89414: reference-related warnings need cleanup before applying code like this
Per CR http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89406#c17545 :
'Here is a third one: Strict Standards: Only variables should be passed by reference in /www/sandwiki/includes/Wiki.php on line 177 '
Offending bit is this:
- SpecialPageFactory::executePath( $this->context->title, $this->context );
+ SpecialPageFactory::executePath( $this->getTitle(), $this->getContext() );
That function demands reference paramters for $title and $context, which is being violated here where we now pass function return values:
public static function executePath( Title &$title, RequestContext &$context, $including = false ) {
The $title does sometimes get replaced within the function body, but $context does not appear to ever be replaced (its *contents* are modified, which does not require passing by reference)
If replacing it is something it should be doing, then we need to be able to replace it upstream presumably, so $this->getTitle() probably isn't appropriate.
The $context probably should have the reference simply removed.
2011-06-03 18:48:59 +00:00
|
|
|
$this->context = $context;
|
|
|
|
|
$this->context->setTitle( $this->parseTitle() );
|
2011-04-03 19:39:39 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 19:33:15 +00:00
|
|
|
/**
|
2011-06-28 17:20:16 +00:00
|
|
|
* Parse the request to get the Title object
|
2008-03-19 19:55:26 +00:00
|
|
|
*
|
|
|
|
|
* @return Title object to be $wgTitle
|
2006-01-11 19:33:15 +00:00
|
|
|
*/
|
2011-04-03 21:32:50 +00:00
|
|
|
private function parseTitle() {
|
2010-12-16 20:11:53 +00:00
|
|
|
global $wgContLang;
|
|
|
|
|
|
2011-06-17 10:07:40 +00:00
|
|
|
$request = $this->context->getRequest();
|
|
|
|
|
$curid = $request->getInt( 'curid' );
|
|
|
|
|
$title = $request->getVal( 'title' );
|
2010-11-30 18:44:50 +00:00
|
|
|
|
2011-06-17 10:07:40 +00:00
|
|
|
if ( $request->getCheck( 'search' ) ) {
|
2010-12-06 17:42:14 +00:00
|
|
|
// Compatibility with old search URLs which didn't use Special:Search
|
|
|
|
|
// Just check for presence here, so blank requests still
|
|
|
|
|
// show the search page when using ugly URLs (bug 8054).
|
|
|
|
|
$ret = SpecialPage::getTitleFor( 'Search' );
|
2011-04-03 15:56:29 +00:00
|
|
|
} elseif ( $curid ) {
|
2010-06-30 15:50:37 +00:00
|
|
|
// URLs like this are generated by RC, because rc_title isn't always accurate
|
2006-01-11 19:33:15 +00:00
|
|
|
$ret = Title::newFromID( $curid );
|
2011-04-03 19:39:39 +00:00
|
|
|
} elseif ( $title == '' && $this->getAction() != 'delete' ) {
|
2008-10-01 10:02:44 +00:00
|
|
|
$ret = Title::newMainPage();
|
2006-01-11 19:33:15 +00:00
|
|
|
} else {
|
|
|
|
|
$ret = Title::newFromURL( $title );
|
2008-03-19 19:55:26 +00:00
|
|
|
// check variant links so that interwiki links don't have to worry
|
|
|
|
|
// about the possible different language variants
|
2011-07-13 18:05:44 +00:00
|
|
|
if ( count( $wgContLang->getVariants() ) > 1
|
|
|
|
|
&& !is_null( $ret ) && $ret->getArticleID() == 0 )
|
|
|
|
|
{
|
2008-03-26 18:57:37 +00:00
|
|
|
$wgContLang->findVariantLink( $title, $ret );
|
2011-04-04 23:09:21 +00:00
|
|
|
}
|
2006-01-11 19:33:15 +00:00
|
|
|
}
|
2010-06-30 15:50:37 +00:00
|
|
|
// For non-special titles, check for implicit titles
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) {
|
2009-01-07 13:23:12 +00:00
|
|
|
// We can have urls with just ?diff=,?oldid= or even just ?diff=
|
2011-06-17 10:07:40 +00:00
|
|
|
$oldid = $request->getInt( 'oldid' );
|
|
|
|
|
$oldid = $oldid ? $oldid : $request->getInt( 'diff' );
|
2009-01-07 13:23:12 +00:00
|
|
|
// Allow oldid to override a changed or missing title
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( $oldid ) {
|
2009-01-07 13:23:12 +00:00
|
|
|
$rev = Revision::newFromId( $oldid );
|
|
|
|
|
$ret = $rev ? $rev->getTitle() : $ret;
|
2007-06-27 15:30:43 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-04-04 23:09:21 +00:00
|
|
|
|
2011-07-13 18:05:44 +00:00
|
|
|
if ( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ) {
|
2011-08-25 21:03:52 +00:00
|
|
|
$ret = SpecialPage::getTitleFor( 'Badtitle' );
|
2011-04-04 23:09:21 +00:00
|
|
|
}
|
2011-07-13 18:30:47 +00:00
|
|
|
|
2008-03-19 19:55:26 +00:00
|
|
|
return $ret;
|
2006-01-11 19:33:15 +00:00
|
|
|
}
|
2007-01-20 12:59:34 +00:00
|
|
|
|
2011-04-03 21:32:50 +00:00
|
|
|
/**
|
|
|
|
|
* Get the Title object that we'll be acting on, as specified in the WebRequest
|
|
|
|
|
* @return Title
|
|
|
|
|
*/
|
|
|
|
|
public function getTitle(){
|
2011-06-17 10:29:39 +00:00
|
|
|
if( $this->context->getTitle() === null ){
|
|
|
|
|
$this->context->setTitle( $this->parseTitle() );
|
2011-04-03 21:32:50 +00:00
|
|
|
}
|
2011-06-17 10:29:39 +00:00
|
|
|
return $this->context->getTitle();
|
2011-04-03 21:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 12:25:41 +00:00
|
|
|
/**
|
2011-05-26 16:41:11 +00:00
|
|
|
* Performs the request.
|
2008-03-19 19:55:26 +00:00
|
|
|
* - bad titles
|
2011-05-26 16:41:11 +00:00
|
|
|
* - read restriction
|
2008-03-19 19:55:26 +00:00
|
|
|
* - local interwiki redirects
|
|
|
|
|
* - redirect loop
|
|
|
|
|
* - special pages
|
2011-05-26 16:41:11 +00:00
|
|
|
* - normal pages
|
2008-03-19 19:55:26 +00:00
|
|
|
*
|
2011-06-25 17:59:42 +00:00
|
|
|
* @return void
|
2006-01-11 12:25:41 +00:00
|
|
|
*/
|
2011-07-13 18:30:47 +00:00
|
|
|
private function performRequest() {
|
2011-05-16 16:46:30 +00:00
|
|
|
global $wgServer, $wgUsePathInfo;
|
|
|
|
|
|
2008-03-19 19:55:26 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2010-10-31 15:35:01 +00:00
|
|
|
|
2011-06-17 10:29:39 +00:00
|
|
|
$request = $this->context->getRequest();
|
|
|
|
|
$title = $this->context->getTitle();
|
|
|
|
|
$output = $this->context->getOutput();
|
|
|
|
|
$user = $this->context->getUser();
|
|
|
|
|
|
|
|
|
|
if ( $request->getVal( 'printable' ) === 'yes' ) {
|
|
|
|
|
$output->setPrintable();
|
2011-05-26 16:41:11 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-25 17:59:42 +00:00
|
|
|
$pageView = false; // was an article or special page viewed?
|
|
|
|
|
|
|
|
|
|
wfRunHooks( 'BeforeInitialize',
|
|
|
|
|
array( &$title, null, &$output, &$user, $request, $this ) );
|
|
|
|
|
|
2009-12-07 18:28:25 +00:00
|
|
|
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
|
2011-08-25 21:03:52 +00:00
|
|
|
if ( is_null( $title ) || ( ( $title->getDBkey() == '' ) && ( $title->getInterwiki() == '' ) ) ) {
|
|
|
|
|
$this->context->title = SpecialPage::getTitleFor( 'Badtitle' );
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new ErrorPageError( 'badtitle', 'badtitletext' );
|
2011-05-26 16:41:11 +00:00
|
|
|
// If the user is not logged in, the Namespace:title of the article must be in
|
|
|
|
|
// the Read array in order for the user to see it. (We have to check here to
|
|
|
|
|
// catch special pages etc. We check again in Article::view())
|
2011-06-17 16:05:35 +00:00
|
|
|
} elseif ( !$title->userCanRead() ) {
|
2011-06-17 10:29:39 +00:00
|
|
|
$output->loginToUse();
|
2009-09-28 03:43:07 +00:00
|
|
|
// Interwiki redirects
|
2011-06-17 16:05:35 +00:00
|
|
|
} elseif ( $title->getInterwiki() != '' ) {
|
2011-06-17 10:29:39 +00:00
|
|
|
$rdfrom = $request->getVal( 'rdfrom' );
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( $rdfrom ) {
|
2011-06-17 10:29:39 +00:00
|
|
|
$url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
|
2006-01-11 13:28:23 +00:00
|
|
|
} else {
|
2011-06-17 10:29:39 +00:00
|
|
|
$query = $request->getValues();
|
2009-08-04 16:31:19 +00:00
|
|
|
unset( $query['title'] );
|
2011-06-17 10:29:39 +00:00
|
|
|
$url = $title->getFullURL( $query );
|
2006-01-11 13:28:23 +00:00
|
|
|
}
|
2011-04-04 23:09:21 +00:00
|
|
|
// Check for a redirect loop
|
2011-07-13 18:05:44 +00:00
|
|
|
if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url )
|
|
|
|
|
&& $title->isLocal() )
|
|
|
|
|
{
|
2011-03-26 21:06:37 +00:00
|
|
|
// 301 so google et al report the target as the actual url.
|
2011-06-17 10:29:39 +00:00
|
|
|
$output->redirect( $url, 301 );
|
2006-01-11 13:28:23 +00:00
|
|
|
} else {
|
2011-08-25 21:03:52 +00:00
|
|
|
$this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
|
2009-09-23 00:34:57 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new ErrorPageError( 'badtitle', 'badtitletext' );
|
2006-01-11 13:28:23 +00:00
|
|
|
}
|
2009-12-21 18:55:42 +00:00
|
|
|
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
|
2011-06-17 16:05:35 +00:00
|
|
|
} elseif ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted()
|
2011-07-13 18:05:44 +00:00
|
|
|
&& ( $request->getVal( 'title' ) === null ||
|
|
|
|
|
$title->getPrefixedDBKey() != $request->getVal( 'title' ) )
|
|
|
|
|
&& !count( $request->getValueNames( array( 'action', 'title' ) ) ) )
|
2006-01-11 12:56:13 +00:00
|
|
|
{
|
2011-06-17 10:29:39 +00:00
|
|
|
if ( $title->getNamespace() == NS_SPECIAL ) {
|
|
|
|
|
list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
|
2010-11-10 08:22:00 +00:00
|
|
|
if ( $name ) {
|
2011-06-17 10:29:39 +00:00
|
|
|
$title = SpecialPage::getTitleFor( $name, $subpage );
|
2010-11-10 08:22:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-08-19 13:25:43 +00:00
|
|
|
$targetUrl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
|
2007-01-03 09:15:11 +00:00
|
|
|
// Redirect to canonical url, make it a 301 to allow caching
|
2011-06-17 10:29:39 +00:00
|
|
|
if ( $targetUrl == $request->getFullRequestURL() ) {
|
2007-01-03 09:15:11 +00:00
|
|
|
$message = "Redirect loop detected!\n\n" .
|
|
|
|
|
"This means the wiki got confused about what page was " .
|
|
|
|
|
"requested; this sometimes happens when moving a wiki " .
|
|
|
|
|
"to a new server or changing the server configuration.\n\n";
|
2007-01-20 12:59:34 +00:00
|
|
|
|
2011-05-16 16:46:30 +00:00
|
|
|
if ( $wgUsePathInfo ) {
|
2007-01-03 09:15:11 +00:00
|
|
|
$message .= "The wiki is trying to interpret the page " .
|
|
|
|
|
"title from the URL path portion (PATH_INFO), which " .
|
|
|
|
|
"sometimes fails depending on the web server. Try " .
|
|
|
|
|
"setting \"\$wgUsePathInfo = false;\" in your " .
|
|
|
|
|
"LocalSettings.php, or check that \$wgArticlePath " .
|
|
|
|
|
"is correct.";
|
|
|
|
|
} else {
|
|
|
|
|
$message .= "Your web server was detected as possibly not " .
|
|
|
|
|
"supporting URL path components (PATH_INFO) correctly; " .
|
|
|
|
|
"check your LocalSettings.php for a customized " .
|
|
|
|
|
"\$wgArticlePath setting and/or toggle \$wgUsePathInfo " .
|
|
|
|
|
"to true.";
|
|
|
|
|
}
|
2011-09-16 18:50:13 +00:00
|
|
|
throw new HttpError( 500, $message );
|
2007-01-03 09:15:11 +00:00
|
|
|
} else {
|
2011-06-17 10:29:39 +00:00
|
|
|
$output->setSquidMaxage( 1200 );
|
|
|
|
|
$output->redirect( $targetUrl, '301' );
|
2007-01-03 09:15:11 +00:00
|
|
|
}
|
2009-09-28 03:43:07 +00:00
|
|
|
// Special pages
|
2011-06-17 16:05:35 +00:00
|
|
|
} elseif ( NS_SPECIAL == $title->getNamespace() ) {
|
2011-06-25 17:59:42 +00:00
|
|
|
$pageView = true;
|
|
|
|
|
// Actions that need to be made when we have a special pages
|
2011-06-17 10:29:39 +00:00
|
|
|
SpecialPageFactory::executePath( $title, $this->context );
|
2006-01-11 12:25:41 +00:00
|
|
|
} else {
|
2011-05-26 16:41:11 +00:00
|
|
|
// ...otherwise treat it as an article view. The article
|
|
|
|
|
// may be a redirect to another article or URL.
|
|
|
|
|
$article = $this->initializeArticle();
|
|
|
|
|
if ( is_object( $article ) ) {
|
2011-06-25 17:59:42 +00:00
|
|
|
$pageView = true;
|
2011-06-18 14:55:22 +00:00
|
|
|
/**
|
|
|
|
|
* $wgArticle is deprecated, do not use it. This will possibly be removed
|
|
|
|
|
* entirely in 1.20 or 1.21
|
2011-07-18 23:01:08 +00:00
|
|
|
* @deprecated since 1.18
|
2011-06-18 14:55:22 +00:00
|
|
|
*/
|
|
|
|
|
global $wgArticle;
|
|
|
|
|
$wgArticle = $article;
|
2011-06-21 23:28:50 +00:00
|
|
|
|
2011-05-26 16:41:11 +00:00
|
|
|
$this->performAction( $article );
|
2011-05-26 19:56:42 +00:00
|
|
|
} elseif ( is_string( $article ) ) {
|
2011-06-17 10:29:39 +00:00
|
|
|
$output->redirect( $article );
|
2011-05-26 16:41:11 +00:00
|
|
|
} else {
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL" );
|
|
|
|
|
}
|
2006-01-11 12:25:41 +00:00
|
|
|
}
|
2011-06-25 17:59:42 +00:00
|
|
|
|
|
|
|
|
if ( $pageView ) {
|
|
|
|
|
// Promote user to any groups they meet the criteria for
|
|
|
|
|
$user->addAutopromoteOnceGroups( 'onView' );
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-19 19:55:26 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2006-01-11 12:25:41 +00:00
|
|
|
}
|
2006-01-10 14:58:06 +00:00
|
|
|
|
2006-01-11 12:25:41 +00:00
|
|
|
/**
|
2006-01-13 00:29:20 +00:00
|
|
|
* Create an Article object of the appropriate class for the given page.
|
2008-03-19 19:55:26 +00:00
|
|
|
*
|
2011-07-18 23:01:08 +00:00
|
|
|
* @deprecated in 1.18; use Article::newFromTitle() instead
|
2008-05-17 10:15:59 +00:00
|
|
|
* @param $title Title
|
2011-09-15 15:19:49 +00:00
|
|
|
* @param $context IContextSource
|
2008-03-19 19:55:26 +00:00
|
|
|
* @return Article object
|
2006-01-11 12:25:41 +00:00
|
|
|
*/
|
2011-09-15 15:19:49 +00:00
|
|
|
public static function articleFromTitle( $title, IContextSource $context ) {
|
2011-05-22 18:38:04 +00:00
|
|
|
return Article::newFromTitle( $title, $context );
|
2006-01-13 00:29:20 +00:00
|
|
|
}
|
2007-01-20 12:59:34 +00:00
|
|
|
|
2010-12-16 20:11:53 +00:00
|
|
|
/**
|
2011-07-12 11:53:58 +00:00
|
|
|
* Returns the action that will be executed, not necessarily the one passed
|
2010-12-16 20:11:53 +00:00
|
|
|
* passed through the "action" parameter. Actions disabled in
|
|
|
|
|
* $wgDisabledActions will be replaced by "nosuchaction"
|
|
|
|
|
*
|
|
|
|
|
* @return String: action
|
|
|
|
|
*/
|
2011-04-03 19:39:39 +00:00
|
|
|
public function getAction() {
|
2011-07-12 11:53:58 +00:00
|
|
|
global $wgDisabledActions;
|
2010-12-16 20:11:53 +00:00
|
|
|
|
2011-06-17 10:29:39 +00:00
|
|
|
$request = $this->context->getRequest();
|
|
|
|
|
$action = $request->getVal( 'action', 'view' );
|
2010-12-16 20:11:53 +00:00
|
|
|
|
|
|
|
|
// Check for disabled actions
|
2011-07-12 11:53:58 +00:00
|
|
|
if ( in_array( $action, $wgDisabledActions ) ) {
|
2011-08-03 22:08:24 +00:00
|
|
|
return 'nosuchaction';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Workaround for bug #20966: inability of IE to provide an action dependent
|
|
|
|
|
// on which submit button is clicked.
|
|
|
|
|
if ( $action === 'historysubmit' ) {
|
2011-06-17 10:29:39 +00:00
|
|
|
if ( $request->getBool( 'revisiondelete' ) ) {
|
2011-08-03 22:08:24 +00:00
|
|
|
return 'revisiondelete';
|
2010-12-16 20:11:53 +00:00
|
|
|
} else {
|
2011-08-03 22:08:24 +00:00
|
|
|
return 'view';
|
2010-12-16 20:11:53 +00:00
|
|
|
}
|
|
|
|
|
} elseif ( $action == 'editredlink' ) {
|
2011-08-03 22:08:24 +00:00
|
|
|
return 'edit';
|
2010-12-16 20:11:53 +00:00
|
|
|
}
|
2011-07-18 23:01:08 +00:00
|
|
|
|
2010-12-16 20:11:53 +00:00
|
|
|
return $action;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-13 00:29:20 +00:00
|
|
|
/**
|
2011-05-22 17:59:47 +00:00
|
|
|
* Initialize the main Article object for "standard" actions (view, etc)
|
2006-01-13 00:29:20 +00:00
|
|
|
* Create an Article object for the page, following redirects if needed.
|
2008-03-19 19:55:26 +00:00
|
|
|
*
|
2006-01-13 00:29:20 +00:00
|
|
|
* @return mixed an Article, or a string to redirect to another URL
|
|
|
|
|
*/
|
2011-04-03 21:32:50 +00:00
|
|
|
private function initializeArticle() {
|
2011-05-16 16:46:30 +00:00
|
|
|
global $wgDisableHardRedirects;
|
|
|
|
|
|
2008-03-19 19:55:26 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2007-01-20 12:59:34 +00:00
|
|
|
|
2011-06-17 10:29:39 +00:00
|
|
|
$request = $this->context->getRequest();
|
|
|
|
|
$title = $this->context->getTitle();
|
|
|
|
|
|
|
|
|
|
$action = $request->getVal( 'action', 'view' );
|
|
|
|
|
$article = Article::newFromTitle( $title, $this->context );
|
2010-06-30 15:50:37 +00:00
|
|
|
// NS_MEDIAWIKI has no redirects.
|
|
|
|
|
// It is also used for CSS/JS, so performance matters here...
|
2011-06-17 10:29:39 +00:00
|
|
|
if ( $title->getNamespace() == NS_MEDIAWIKI ) {
|
2008-12-23 22:48:44 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return $article;
|
|
|
|
|
}
|
2006-01-13 00:29:20 +00:00
|
|
|
// Namespace might change when using redirects
|
2008-05-08 20:15:09 +00:00
|
|
|
// Check for redirects ...
|
2011-06-17 10:29:39 +00:00
|
|
|
$file = ( $title->getNamespace() == NS_FILE ) ? $article->getFile() : null;
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
|
2011-06-17 10:29:39 +00:00
|
|
|
&& !$request->getVal( 'oldid' ) && // ... and are not old revisions
|
|
|
|
|
!$request->getVal( 'diff' ) && // ... and not when showing diff
|
|
|
|
|
$request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to
|
2008-12-09 03:25:02 +00:00
|
|
|
// ... and the article is not a non-redirect image page with associated file
|
|
|
|
|
!( is_object( $file ) && $file->exists() && !$file->getRedirected() ) )
|
|
|
|
|
{
|
2010-06-30 15:50:37 +00:00
|
|
|
// Give extensions a change to ignore/handle redirects as needed
|
2008-07-04 09:38:12 +00:00
|
|
|
$ignoreRedirect = $target = false;
|
2010-12-01 20:22:45 +00:00
|
|
|
|
|
|
|
|
wfRunHooks( 'InitializeArticleMaybeRedirect',
|
2011-06-17 10:29:39 +00:00
|
|
|
array( &$title, &$request, &$ignoreRedirect, &$target, &$article ) );
|
2008-12-09 03:25:02 +00:00
|
|
|
|
2009-09-06 10:09:45 +00:00
|
|
|
// Follow redirects only for... redirects.
|
|
|
|
|
// If $target is set, then a hook wanted to redirect.
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( !$ignoreRedirect && ( $target || $article->isRedirect() ) ) {
|
2010-06-30 15:50:37 +00:00
|
|
|
// Is the target already set by an extension?
|
2008-07-04 09:38:12 +00:00
|
|
|
$target = $target ? $target : $article->followRedirect();
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( is_string( $target ) ) {
|
2011-05-16 16:46:30 +00:00
|
|
|
if ( !$wgDisableHardRedirects ) {
|
2006-01-14 21:19:17 +00:00
|
|
|
// we'll need to redirect
|
2009-09-23 00:34:57 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2006-01-14 21:19:17 +00:00
|
|
|
return $target;
|
|
|
|
|
}
|
2006-01-11 09:24:34 +00:00
|
|
|
}
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( is_object( $target ) ) {
|
2008-03-19 19:55:26 +00:00
|
|
|
// Rewrite environment to redirected article
|
Provisional revert of r89406, r89414: reference-related warnings need cleanup before applying code like this
Per CR http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89406#c17545 :
'Here is a third one: Strict Standards: Only variables should be passed by reference in /www/sandwiki/includes/Wiki.php on line 177 '
Offending bit is this:
- SpecialPageFactory::executePath( $this->context->title, $this->context );
+ SpecialPageFactory::executePath( $this->getTitle(), $this->getContext() );
That function demands reference paramters for $title and $context, which is being violated here where we now pass function return values:
public static function executePath( Title &$title, RequestContext &$context, $including = false ) {
The $title does sometimes get replaced within the function body, but $context does not appear to ever be replaced (its *contents* are modified, which does not require passing by reference)
If replacing it is something it should be doing, then we need to be able to replace it upstream presumably, so $this->getTitle() probably isn't appropriate.
The $context probably should have the reference simply removed.
2011-06-03 18:48:59 +00:00
|
|
|
$rarticle = Article::newFromTitle( $target, $this->context );
|
2011-01-03 19:50:01 +00:00
|
|
|
$rarticle->loadPageData();
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) {
|
2011-06-17 10:29:39 +00:00
|
|
|
$rarticle->setRedirectedFrom( $title );
|
2006-01-14 21:19:17 +00:00
|
|
|
$article = $rarticle;
|
2011-06-17 10:29:39 +00:00
|
|
|
$this->context->setTitle( $target );
|
2006-01-14 21:19:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2011-06-17 10:29:39 +00:00
|
|
|
$this->context->setTitle( $article->getTitle() );
|
2006-01-13 00:29:20 +00:00
|
|
|
}
|
2006-01-10 18:41:23 +00:00
|
|
|
}
|
2011-07-13 18:30:47 +00:00
|
|
|
|
2008-03-19 19:55:26 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2006-01-10 21:45:56 +00:00
|
|
|
return $article;
|
2006-01-10 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 15:46:01 +00:00
|
|
|
/**
|
2011-04-03 15:56:29 +00:00
|
|
|
* Cleaning up request by doing deferred updates, DB transaction, and the output
|
2006-01-11 15:46:01 +00:00
|
|
|
*/
|
2011-04-03 19:39:39 +00:00
|
|
|
public function finalCleanup() {
|
2008-03-19 19:55:26 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2010-06-30 15:50:37 +00:00
|
|
|
// Now commit any transactions, so that unreported errors after
|
|
|
|
|
// output() don't roll back the whole DB transaction
|
2008-03-30 09:48:15 +00:00
|
|
|
$factory = wfGetLBFactory();
|
2008-09-12 17:01:41 +00:00
|
|
|
$factory->commitMasterChanges();
|
2010-06-30 15:50:37 +00:00
|
|
|
// Output everything!
|
2011-06-17 10:29:39 +00:00
|
|
|
$this->context->getOutput()->output();
|
2010-06-30 15:50:37 +00:00
|
|
|
// Do any deferred jobs
|
2011-09-10 06:50:30 +00:00
|
|
|
DeferredUpdates::doUpdates( 'commit' );
|
2008-09-12 17:01:41 +00:00
|
|
|
$this->doJobs();
|
2008-03-19 19:55:26 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2006-01-11 15:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
2006-02-24 01:56:31 +00:00
|
|
|
/**
|
|
|
|
|
* Do a job from the job queue
|
|
|
|
|
*/
|
2011-04-03 15:56:29 +00:00
|
|
|
private function doJobs() {
|
2010-12-09 15:59:44 +00:00
|
|
|
global $wgJobRunRate;
|
2007-01-20 12:59:34 +00:00
|
|
|
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( $wgJobRunRate <= 0 || wfReadOnly() ) {
|
2006-02-24 01:56:31 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( $wgJobRunRate < 1 ) {
|
2006-02-24 01:56:31 +00:00
|
|
|
$max = mt_getrandmax();
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( mt_rand( 0, $max ) > $max * $wgJobRunRate ) {
|
2006-02-24 01:56:31 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$n = 1;
|
|
|
|
|
} else {
|
2010-12-09 15:59:44 +00:00
|
|
|
$n = intval( $wgJobRunRate );
|
2006-02-24 01:56:31 +00:00
|
|
|
}
|
2011-06-17 10:07:40 +00:00
|
|
|
|
2008-03-19 19:55:26 +00:00
|
|
|
while ( $n-- && false != ( $job = Job::pop() ) ) {
|
2006-02-24 01:56:31 +00:00
|
|
|
$output = $job->toString() . "\n";
|
2006-07-03 16:41:07 +00:00
|
|
|
$t = -wfTime();
|
|
|
|
|
$success = $job->run();
|
|
|
|
|
$t += wfTime();
|
2011-04-03 15:56:29 +00:00
|
|
|
$t = round( $t * 1000 );
|
|
|
|
|
if ( !$success ) {
|
2006-07-03 16:41:07 +00:00
|
|
|
$output .= "Error: " . $job->getLastError() . ", Time: $t ms\n";
|
|
|
|
|
} else {
|
|
|
|
|
$output .= "Success, Time: $t ms\n";
|
2006-02-24 01:56:31 +00:00
|
|
|
}
|
2006-07-04 14:26:14 +00:00
|
|
|
wfDebugLog( 'jobqueue', $output );
|
2006-02-24 01:56:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-01-20 12:59:34 +00:00
|
|
|
|
2006-01-11 15:46:01 +00:00
|
|
|
/**
|
|
|
|
|
* Ends this task peacefully
|
|
|
|
|
*/
|
2011-04-03 15:56:29 +00:00
|
|
|
public function restInPeace() {
|
2010-08-21 16:41:53 +00:00
|
|
|
MessageCache::logMessages();
|
2006-07-14 05:35:31 +00:00
|
|
|
wfLogProfilingData();
|
2010-06-30 15:50:37 +00:00
|
|
|
// Commit and close up!
|
2011-06-17 16:42:58 +00:00
|
|
|
$factory = wfGetLBFactory();
|
2009-04-21 01:51:17 +00:00
|
|
|
$factory->commitMasterChanges();
|
|
|
|
|
$factory->shutdown();
|
2011-06-17 16:42:58 +00:00
|
|
|
wfDebug( "Request ended normally\n" );
|
2006-01-11 15:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 12:25:41 +00:00
|
|
|
/**
|
|
|
|
|
* Perform one of the "standard" actions
|
2008-03-19 19:55:26 +00:00
|
|
|
*
|
2008-05-17 10:15:59 +00:00
|
|
|
* @param $article Article
|
2006-01-11 12:25:41 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
private function performAction( Page $article ) {
|
2011-05-26 00:08:16 +00:00
|
|
|
global $wgSquidMaxage, $wgUseExternalEditor;
|
2011-05-16 16:46:30 +00:00
|
|
|
|
2008-12-11 00:54:21 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
|
|
|
|
|
2011-06-17 10:29:39 +00:00
|
|
|
$request = $this->context->getRequest();
|
|
|
|
|
$output = $this->context->getOutput();
|
|
|
|
|
$title = $this->context->getTitle();
|
|
|
|
|
$user = $this->context->getUser();
|
|
|
|
|
|
2011-06-25 17:59:42 +00:00
|
|
|
if ( !wfRunHooks( 'MediaWikiPerformAction',
|
|
|
|
|
array( $output, $article, $title, $user, $request, $this ) ) )
|
2011-04-03 21:32:50 +00:00
|
|
|
{
|
2008-12-11 00:54:21 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2007-11-06 01:16:25 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 10:38:29 +00:00
|
|
|
$act = $this->getAction();
|
2009-10-06 06:30:24 +00:00
|
|
|
|
2011-05-23 17:55:26 +00:00
|
|
|
$action = Action::factory( $act, $article );
|
2011-07-13 22:11:53 +00:00
|
|
|
if ( $action instanceof Action ) {
|
2011-04-14 10:38:29 +00:00
|
|
|
$action->show();
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch( $act ) {
|
2006-01-10 14:58:06 +00:00
|
|
|
case 'view':
|
2011-06-17 10:29:39 +00:00
|
|
|
$output->setSquidMaxage( $wgSquidMaxage );
|
2006-01-10 14:58:06 +00:00
|
|
|
$article->view();
|
|
|
|
|
break;
|
2011-06-03 05:44:28 +00:00
|
|
|
case 'raw': // includes JS/CSS
|
|
|
|
|
wfProfileIn( __METHOD__ . '-raw' );
|
|
|
|
|
$raw = new RawPage( $article );
|
|
|
|
|
$raw->view();
|
|
|
|
|
wfProfileOut( __METHOD__ . '-raw' );
|
|
|
|
|
break;
|
2011-04-13 23:36:27 +00:00
|
|
|
case 'delete':
|
2006-01-10 14:58:06 +00:00
|
|
|
case 'protect':
|
|
|
|
|
case 'unprotect':
|
|
|
|
|
case 'render':
|
2011-04-14 10:38:29 +00:00
|
|
|
$article->$act();
|
2006-01-10 14:58:06 +00:00
|
|
|
break;
|
|
|
|
|
case 'submit':
|
2011-04-03 15:56:29 +00:00
|
|
|
if ( session_id() == '' ) {
|
2011-04-04 23:09:21 +00:00
|
|
|
// Send a cookie so anons get talk message notifications
|
2007-02-05 21:42:48 +00:00
|
|
|
wfSetupSession();
|
2006-01-10 14:58:06 +00:00
|
|
|
}
|
2011-04-04 23:09:21 +00:00
|
|
|
// Continue...
|
2006-01-10 14:58:06 +00:00
|
|
|
case 'edit':
|
2011-06-17 10:29:39 +00:00
|
|
|
if ( wfRunHooks( 'CustomEditor', array( $article, $user ) ) ) {
|
|
|
|
|
$internal = $request->getVal( 'internaledit' );
|
|
|
|
|
$external = $request->getVal( 'externaledit' );
|
|
|
|
|
$section = $request->getVal( 'section' );
|
|
|
|
|
$oldid = $request->getVal( 'oldid' );
|
2011-05-16 16:46:30 +00:00
|
|
|
if ( !$wgUseExternalEditor || $act == 'submit' || $internal ||
|
2011-07-13 18:05:44 +00:00
|
|
|
$section || $oldid ||
|
|
|
|
|
( !$user->getOption( 'externaleditor' ) && !$external ) )
|
|
|
|
|
{
|
2007-01-20 19:51:21 +00:00
|
|
|
$editor = new EditPage( $article );
|
|
|
|
|
$editor->submit();
|
2011-07-13 18:05:44 +00:00
|
|
|
} elseif ( $wgUseExternalEditor
|
|
|
|
|
&& ( $external || $user->getOption( 'externaleditor' ) ) )
|
|
|
|
|
{
|
2011-06-17 10:29:39 +00:00
|
|
|
$mode = $request->getVal( 'mode' );
|
2011-07-14 20:19:59 +00:00
|
|
|
$extedit = new ExternalEdit( $article->getTitle(), $mode );
|
2007-01-20 19:51:21 +00:00
|
|
|
$extedit->edit();
|
|
|
|
|
}
|
2006-01-10 14:58:06 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2011-08-07 14:29:28 +00:00
|
|
|
case 'history':
|
|
|
|
|
if ( $request->getFullRequestURL() == $title->getInternalURL( 'action=history' ) ) {
|
|
|
|
|
$output->setSquidMaxage( $wgSquidMaxage );
|
|
|
|
|
}
|
|
|
|
|
$history = new HistoryPage( $article );
|
|
|
|
|
$history->history();
|
|
|
|
|
break;
|
2006-01-10 14:58:06 +00:00
|
|
|
default:
|
2011-04-14 10:38:29 +00:00
|
|
|
if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) {
|
2011-06-17 10:29:39 +00:00
|
|
|
$output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
|
2006-01-10 14:58:06 +00:00
|
|
|
}
|
2006-02-24 07:49:36 +00:00
|
|
|
}
|
2008-12-11 00:54:21 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2005-12-30 12:25:54 +00:00
|
|
|
}
|
2011-06-18 14:50:26 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Run the current MediaWiki instance
|
2011-06-21 23:28:50 +00:00
|
|
|
* index.php just calls this
|
|
|
|
|
*/
|
2011-07-13 18:30:47 +00:00
|
|
|
public function run() {
|
2011-06-18 14:50:26 +00:00
|
|
|
try {
|
|
|
|
|
$this->checkMaxLag( true );
|
|
|
|
|
$this->main();
|
|
|
|
|
$this->restInPeace();
|
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
|
MWExceptionHandler::handle( $e );
|
|
|
|
|
}
|
2011-06-21 23:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-18 14:50:26 +00:00
|
|
|
/**
|
2011-06-21 23:28:50 +00:00
|
|
|
* Checks if the request should abort due to a lagged server,
|
2011-06-18 14:50:26 +00:00
|
|
|
* for given maxlag parameter.
|
2011-06-21 23:28:50 +00:00
|
|
|
*
|
|
|
|
|
* @param boolean $abort True if this class should abort the
|
2011-06-18 14:50:26 +00:00
|
|
|
* script execution. False to return the result as a boolean.
|
|
|
|
|
* @return boolean True if we passed the check, false if we surpass the maxlag
|
|
|
|
|
*/
|
2011-07-13 18:30:47 +00:00
|
|
|
private function checkMaxLag( $abort ) {
|
2011-06-18 14:50:26 +00:00
|
|
|
global $wgShowHostnames;
|
2011-06-21 23:28:50 +00:00
|
|
|
|
2011-06-18 14:50:26 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
|
|
|
|
$maxLag = $this->context->getRequest()->getVal( 'maxlag' );
|
|
|
|
|
if ( !is_null( $maxLag ) ) {
|
|
|
|
|
$lb = wfGetLB(); // foo()->bar() is not supported in PHP4
|
|
|
|
|
list( $host, $lag ) = $lb->getMaxLag();
|
|
|
|
|
if ( $lag > $maxLag ) {
|
|
|
|
|
if ( $abort ) {
|
2011-07-14 17:48:41 +00:00
|
|
|
$resp = $this->context->getRequest()->response();
|
|
|
|
|
$resp->header( 'HTTP/1.1 503 Service Unavailable' );
|
|
|
|
|
$resp->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
|
|
|
|
|
$resp->header( 'X-Database-Lag: ' . intval( $lag ) );
|
|
|
|
|
$resp->header( 'Content-Type: text/plain' );
|
2011-06-18 14:50:26 +00:00
|
|
|
if( $wgShowHostnames ) {
|
|
|
|
|
echo "Waiting for $host: $lag seconds lagged\n";
|
|
|
|
|
} else {
|
|
|
|
|
echo "Waiting for a database server: $lag seconds lagged\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-21 23:28:50 +00:00
|
|
|
|
2011-06-18 14:50:26 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
|
2011-07-13 22:11:53 +00:00
|
|
|
if ( !$abort ) {
|
2011-06-18 14:50:26 +00:00
|
|
|
return false;
|
2011-07-13 22:11:53 +00:00
|
|
|
}
|
2011-06-18 14:50:26 +00:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-13 18:30:47 +00:00
|
|
|
private function main() {
|
2011-06-18 14:50:26 +00:00
|
|
|
global $wgUseFileCache, $wgTitle, $wgUseAjax;
|
2011-06-21 23:28:50 +00:00
|
|
|
|
2011-06-18 15:14:59 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2011-06-21 23:28:50 +00:00
|
|
|
|
2011-06-18 14:50:26 +00:00
|
|
|
# Set title from request parameters
|
|
|
|
|
$wgTitle = $this->getTitle();
|
2011-06-18 21:13:46 +00:00
|
|
|
$action = $this->getAction();
|
2011-07-13 18:30:47 +00:00
|
|
|
$user = $this->context->getUser();
|
2011-06-21 23:28:50 +00:00
|
|
|
|
2011-06-18 14:50:26 +00:00
|
|
|
# Send Ajax requests to the Ajax dispatcher.
|
|
|
|
|
if ( $wgUseAjax && $action == 'ajax' ) {
|
|
|
|
|
$dispatcher = new AjaxDispatcher();
|
|
|
|
|
$dispatcher->performAction();
|
2011-06-18 15:14:59 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2011-06-18 14:50:26 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2011-06-21 23:28:50 +00:00
|
|
|
|
2011-06-25 17:59:42 +00:00
|
|
|
if ( $wgUseFileCache && $wgTitle->getNamespace() != NS_SPECIAL ) {
|
2011-06-18 14:50:26 +00:00
|
|
|
wfProfileIn( 'main-try-filecache' );
|
|
|
|
|
// Raw pages should handle cache control on their own,
|
|
|
|
|
// even when using file cache. This reduces hits from clients.
|
2011-06-25 17:59:42 +00:00
|
|
|
if ( HTMLFileCache::useFileCache() ) {
|
2011-06-18 14:50:26 +00:00
|
|
|
/* Try low-level file cache hit */
|
|
|
|
|
$cache = new HTMLFileCache( $wgTitle, $action );
|
|
|
|
|
if ( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
|
|
|
|
|
/* Check incoming headers to see if client has this cached */
|
2011-07-13 18:05:44 +00:00
|
|
|
$timestamp = $cache->fileCacheTime();
|
|
|
|
|
if ( !$this->context->getOutput()->checkLastModified( $timestamp ) ) {
|
2011-06-18 14:50:26 +00:00
|
|
|
$cache->loadFromFileCache();
|
|
|
|
|
}
|
|
|
|
|
# Do any stats increment/watchlist stuff
|
2011-07-13 18:30:47 +00:00
|
|
|
$article = WikiPage::factory( $wgTitle );
|
|
|
|
|
$article->doViewUpdates( $user );
|
2011-06-18 14:50:26 +00:00
|
|
|
# Tell OutputPage that output is taken care of
|
|
|
|
|
$this->context->getOutput()->disable();
|
|
|
|
|
wfProfileOut( 'main-try-filecache' );
|
2011-06-18 15:14:59 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2011-06-18 14:50:26 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wfProfileOut( 'main-try-filecache' );
|
|
|
|
|
}
|
2011-06-21 23:28:50 +00:00
|
|
|
|
2011-06-18 14:50:26 +00:00
|
|
|
$this->performRequest();
|
2011-06-18 21:13:46 +00:00
|
|
|
$this->finalCleanup();
|
2011-06-21 23:28:50 +00:00
|
|
|
|
2011-06-18 15:14:59 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2011-06-18 14:50:26 +00:00
|
|
|
}
|
2010-08-09 18:54:43 +00:00
|
|
|
}
|